Commit Graph

20059 Commits

Author SHA1 Message Date
Guido van Rossum ff0e6d6ef5 Fix the baffler that Tim reported: sometimes the repr() of an object
looks like <X object at ...>, sometimes it says <X instance at ...>.
Make this uniformly say <X object at ...>.
2001-09-24 16:03:59 +00:00
Fred Drake f244b2e47c Add more signature information and some descriptions for the new APIs
introduced in Python 2.2.
Add documentation for the slice object interface (not complete).
Added version annotations for several of the Python 2.2 APIs already
documented.
2001-09-24 15:31:50 +00:00
Fred Drake 23a78cf1c1 Add more reference count information. 2001-09-24 15:29:47 +00:00
Andrew M. Kuchling 1497b62827 Add link to Unix Review's 2.2 article
Fix two errors
2001-09-24 14:51:16 +00:00
Steven M. Gava c11ccf35f4 start of new config handling stuff 2001-09-24 09:43:17 +00:00
Tim Peters fa26f7cc39 More work on class display:
+ Minor code cleanup, generalization and simplification.

+ "Do something" to make the attribute aggregation more apparent:
    - In text mode, stick a "* " at the front of subgroup header lines.
    - In GUI mode, display a horizontal rule between subgroups.
   For GUI mode, this is a huge improvement, at least under IE.
2001-09-24 08:05:11 +00:00
Tim Peters b47879b239 Try to do for pydoc's GUI mode what the earlier checkin did for text
mode (identify the source class for class attrs; segregate attrs according
to source class, and whether class method, static method, property, plain
method, or data; display data attrs; display docstrings for data attrs
when possible).

Alas, this is mondo ugly, and I'm no HTML guy.  Part of the problem is
that pydoc's GUI mode has always been ugly under IE, largely because
<small> under IE renders docstrings unreadably small (while sometimes
non-docstring text is painfully large).  Another part is that these
segregated listings of attrs would *probably* look much better as bulleted
lists.  Alas, when I tried that, the bullets all ended up on lines by
themselves, before the method names; this is apparently because pydoc
(ab?)uses definition lists for format effects, and at least under IE
if a definition list is the first chunk of a list item, it gets rendered
on a line after the <li> bullet.

An HTML wizard would certainly be welcomed here.
2001-09-24 04:47:19 +00:00
Barry Warsaw 2f60073d2d Added a note about the new email package. 2001-09-24 04:28:10 +00:00
Tim Peters 28355496c1 Part of a partial solution to SF bugs 463378, 463381, 463383, 463384.
This almost entirely replaces how pydoc pumps out class docs, but only
in text mode (like help(whatever) from a Python shell), not in GUI mode.

A class C's attrs are now grouped by the class in which they're defined,
attrs defined by C first, then inherited attrs grouped by alphabetic order
of the defining classes' names.

Within each of those groups, the attrs are subgrouped according to whether
they're plain methods, class methods, static methods, properties, or data.
Note that pydoc never dumped class data attrs before.  If a class data
attr is implemented via a data descriptor, the data docstring (if any)
is also displayed (e.g., file.softspace).

Within a subgroup, the attrs are listed alphabetically.

This is a friggin' mess, and there are bound to be glitches.  Please
beat on it and complain!  Here are three glitches:

1. __new__ gets classifed as 'data', for some reason.  This will
   have to get fixed in inspect.py, but since the latter is already
   looking for any clue that something is a method, pydoc will
   almost certainly not know what to do with it when its classification
   changes.

2. properties are special-cased to death.  Unlike any other kind of
   function or method, they don't have a __name__ attr, so none of
   pydoc's usual code can deal with them.  Worse, the getter and
   setter and del'er methods associated with a property don't appear
   to be discoverable from Python, so there's really nothing I can
   think of to do here beyond just listing their names.

   Note that a property can't be given a docstring, either (or at least
   I've been unable to sneak one in) -- perhaps the property()
   constructor could take an optional doc argument?

3. In a nested-scopes world, pydoc still doesn't know anything about
   nesting, so e.g. classes nested in functions are effectively invisible.
2001-09-23 21:29:55 +00:00
Martin v. Löwis 894258cebe Reactivate participation of expat parsers in GC. Fixes bug #462710. 2001-09-23 10:20:10 +00:00
Tim Peters 8ca177bd21 Install the new Lib/email pkg.
Create & populate the new Lib/test/data directory.
2001-09-23 07:02:29 +00:00
Tim Peters 2c9aa5ea8d Generalize file.writelines() to allow iterable objects. 2001-09-23 04:06:05 +00:00
Barry Warsaw d31db7e939 The test data (mostly example messages) for the email package test
suite.  Note that other tests can put input data in this directory.
2001-09-23 03:19:33 +00:00
Barry Warsaw 4107585a67 An extensive test suite for the email package. 2001-09-23 03:18:13 +00:00
Barry Warsaw ba92580f01 The email package version 1.0, prototyped as mimelib
<http://sf.net/projects/mimelib>.  There /are/ API differences between
mimelib and email, but most of the implementations are shared (except
where cool Py2.2 stuff like generators are used).
2001-09-23 03:17:28 +00:00
Fred Drake d61d0d3f6d Added API information for the PyCallIter_*() and PySeqIter_*() functions.
Added signatures for some new PyType_*() functions.
2001-09-23 02:05:26 +00:00
Tim Peters 13b49d3374 New function classify_class_attrs(). As a number of SF bug reports
point out, pydoc doesn't tell you where class attributes were defined,
gets several new 2.2 features wrong, and isn't aware of some new features
checked in on Thursday <wink>.  pydoc is hampered in part because
inspect.py has the same limitations.  Alas, I can't think of a way to
fix this within the current architecture of inspect/pydoc:  it's simply
not possible in 2.2 to figure out everything needed just from examining
the object you get back from class.attr.  You also need the class
context, and the method resolution order, and tests against various things
that simply didn't exist before.  OTOH, knowledge of how to do that is
getting quite complex, so doesn't belong in pydoc.

classify_class_attrs takes a different approach, analyzing all
the class attrs "at once", and returning the most interesting stuff for
each, all in one gulp.  pydoc needs to be reworked to use this for
classes (instead of the current "filter dir(class) umpteen times against
assorted predicates" approach).
2001-09-23 02:00:29 +00:00
Tim Peters 42b6877293 Fix restore (difflib.restore() became a generator too). 2001-09-22 21:59:18 +00:00
Tim Peters 8a9c284437 Make difflib.ndiff() and difflib.Differ.compare() generators. This
restores the 2.1 ability of Tools/scripts/ndiff.py to start producing
output before the entire comparison is complete.
2001-09-22 21:30:22 +00:00
Guido van Rossum 380bad1b4e Add note about __getattribute__. 2001-09-22 17:10:44 +00:00
Tim Peters e0b2d7ac9a Add a function to compute a class's method resolution order. This is
easy for 2.2 new-style classes, but trickier for classic classes, and
different approaches are needed "depending".  The function will allow
later code to treat all flavors of classes uniformly.
2001-09-22 06:10:55 +00:00
Tim Peters c377b16d12 Since the most likely failure mode for an expected-output test is a change
somewhere inside a line, use ndiff so that intraline difference marking
can point out what changed within a line.  I don't remember diff-style
abbreviations either (haven't used it since '94, except to produce
patches), so say the rest in English too.
2001-09-22 05:31:03 +00:00
Barry Warsaw 58b072d53f {String,cString}IO.StringIO's support iteration. 2001-09-22 04:44:21 +00:00
Barry Warsaw 3e8be722d9 I_getiter(): Function for the tp_iter slot of Itype so that
cStringIO's can participate in the iterator protocol.

Fill the Itype.tp_iter slot with I_getiter()
2001-09-22 04:36:49 +00:00
Barry Warsaw bdefa0b3de __iter__(): New method so that StringIO's can participate in the
iterator protocol.
2001-09-22 04:34:54 +00:00
Fred Drake 038d26410d Note that files are iterable; describe what the iterator returns.
This closes SF bug #463738.
2001-09-22 04:34:48 +00:00
Barry Warsaw 7f8ff471f8 Converted test_StringIO.py to use unittest, so
Lib/test/output/test_StringIO is no longer necessary.

Also, added a test of the iterator protocol that's just been added to
StringIO's and cStringIO's.
2001-09-22 04:33:47 +00:00
Fred Drake 3208d4b387 Start of a test to make sure the profiler/tracer support in the core
interpreter is reporting what we expect to see.
2001-09-22 04:28:19 +00:00
Guido van Rossum 19c1cd5b35 Add the __getattr__ hook back. The rules are now:
- if __getattribute__ exists, it is called first;
  if it doesn't exists, PyObject_GenericGetAttr is called first.
- if the above raises AttributeError, and __getattr__ exists,
  it is called.
2001-09-21 21:24:49 +00:00
Fred Drake 56dd35bd44 Bump version number. 2001-09-21 21:18:16 +00:00
Fred Drake c69205526a Added reference to Tutorial section on user-defined exceptions for
information on defining new exceptions.
This closes SF bug #443559.
2001-09-21 21:12:30 +00:00
Fred Drake 13af42822c Exceptions in interactive examlpes did not always include the indication of
the source file using "in ?".

Added a description of the bare "raise" statement.

Added more description and examples for user-defined exceptions; this
is part of a response to SF bug #443559.
2001-09-21 21:10:05 +00:00
Guido van Rossum cf691935bb reportdiff(): print a "plain diff" style diff.
XXX This should really be a unified diff, but I can't be bothered.
2001-09-21 21:06:22 +00:00
Guido van Rossum 0a07639779 Oops. I didn't expect that some tests (test_cookie) have expected
output *and* doctest stuff.  Assuming the doctest stuff comes after the
expected output, this fixes that.
2001-09-21 20:45:44 +00:00
Guido van Rossum 0fcca4e815 Change the way unexpected output is reported: rather than stopping at
the first difference, let the test run till completion, then gather
all the output and compare it to the expected output using difflib.

XXX Still to do: produce diff output that only shows the sections that
differ; currently it produces ndiff-style output because that's the
easiest to produce with difflib, but this becomes a liability when the
output is voluminous and there are only a few differences.
2001-09-21 20:31:52 +00:00
Guido van Rossum 867a8d2e26 Change the name of the __getattr__ special method for new-style
classes to __getattribute__, to make it crystal-clear that it doesn't
have the same semantics as overriding __getattr__ on classic classes.

This is a halfway checkin -- I'll proceed to add a __getattr__ hook
that works the way it works in classic classes.
2001-09-21 19:29:08 +00:00
Guido van Rossum dbb718fa87 Make these modules work when Python is compiled without Unicode support. 2001-09-21 19:22:34 +00:00
Guido van Rossum 11310bf867 Add tests for repr() of strings containing string quotes as well. 2001-09-21 15:46:41 +00:00
Guido van Rossum ad9744a67a Fix a bug in rendering of \\ by repr() -- it rendered as \\\ instead
of \\.
2001-09-21 15:38:17 +00:00
Guido van Rossum e4874aeab0 Test basic functioning of unicode repr(). (If this breaks Jython,
please let me know and we'll figure out how to fix the test.)
2001-09-21 15:36:41 +00:00
Guido van Rossum 8b9cc7e69e Add a small test to verify that member and getset descriptors now have
docstrings (using file.closed and file.name as examples).
2001-09-20 21:49:53 +00:00
Guido van Rossum 32d34c809f Add optional docstrings to getset descriptors. Fortunately, there's
no backwards compatibility to worry about, so I just pushed the
'closure' struct member to the back -- it's never used in the current
code base (I may eliminate it, but that's more work because the getter
and setter signatures would have to change.)

As examples, I added actual docstrings to the getset attributes of a
few types: file.closed, xxsubtype.spamdict.state.
2001-09-20 21:45:26 +00:00
Guido van Rossum a56b42b1ba Change testdescr.py to use the test_main() approach. 2001-09-20 21:39:07 +00:00
Fred Drake 2e2be3760c Change the PyUnit-based tests to use the test_main() approach. This
allows using the tests with unittest.py as a script.  The tests will
still run when run as a script themselves.
2001-09-20 21:33:42 +00:00
Guido van Rossum 6f7993765a Add optional docstrings to member descriptors. For backwards
compatibility, this required all places where an array of "struct
memberlist" structures was declared that is referenced from a type's
tp_members slot to change the type of the structure to PyMemberDef;
"struct memberlist" is now only used by old code that still calls
PyMember_Get/Set.  The code in PyObject_GenericGetAttr/SetAttr now
calls the new APIs PyMember_GetOne/SetOne, which take a PyMemberDef
argument.

As examples, I added actual docstrings to the attributes of a few
types: file, complex, instance method, super, and xxsubtype.spamlist.

Also converted the symtable to new style getattr.
2001-09-20 20:46:19 +00:00
Fred Drake e0af35eb69 Fill in a few more descriptions for xml.parsers.expat. 2001-09-20 20:43:28 +00:00
Tim Peters 2e29bfbe1a Document new file() constructor, with the body of open()'s text, plus a
"new in 2.2" blurb at the end.  Replace open()'s text by pointing back
to file().
2001-09-20 19:55:29 +00:00
Fred Drake f47d8ef683 Document all the Py*_CheckExact() functions.
Document many more of the PyLong_{As,From}*() functions.
2001-09-20 19:18:52 +00:00
Guido van Rossum 461591eb17 PyLocale_setlocale(): silence compiler warning about free() of a const
char *.
2001-09-20 19:18:30 +00:00
Marc-André Lemburg 3508e30861 Fix Unicode .join() method to raise a TypeError for sequence
elements which are not Unicode objects or strings. (This matches
the string.join() behaviour.)

Fix a memory leak in the .join() method which occurs in case
the Unicode resize fails.

Restore the test_unicode output.
2001-09-20 17:22:58 +00:00