summaryrefslogtreecommitdiffstats
path: root/Lib
Commit message (Collapse)AuthorAgeFilesLines
* Make properties discoverable from Python:Tim Peters2001-09-241-2/+28
| | | | | | | | | | | | | - property() now takes 4 keyword arguments: fget, fset, fdel, doc. Note that the real purpose of the 'f' prefix is to make fdel fit in ('del' is a keyword, so can't used as a keyword argument name). - These map to visible readonly attributes 'fget', 'fset', 'fdel', and '__doc__' in the property object. - fget/fset/fdel weren't discoverable from Python before. - __doc__ is new, and allows to associate a docstring with a property.
* Added several new tests to check the behavior with respect to doctypeFred Drake2001-09-241-6/+77
| | | | | | | declarations and weird markup that we used to accept & ignore that recent versions raised an exception for; the original behavior has been restored and augmented (the user can decide what to do if they care; the default is to ignore it as done in early versions).
* Adapt to use the test_main() approach.Fred Drake2001-09-241-1/+6
|
* Re-factor the SGMLParser class to use the new markupbase.ParserBase class.Fred Drake2001-09-241-75/+34
| | | | | | | | | | Use a new internal method, error(), consistently to raise parse errors; the new base class also uses this. Adjust the parse_comment() method to return the new offset into the buffer instead of the number of characters scanned; this was the only helper method that did it this way, so we have better consistency now. Required to share the new base class. This fixes SF bug #448482 and #453706.
* Re-factor the HTMLParser class to use the new markupbase.ParserBase class.Fred Drake2001-09-241-305/+19
| | | | | Use a new internal method, error(), consistently to raise parse errors; the new base class also uses this.
* Be consistent about the string module.Fred Drake2001-09-241-1/+1
|
* New base class for the SGMLParser and HTMLParser classes from the sgmllibFred Drake2001-09-241-0/+306
| | | | | | | | | | and HTMLParser modules (and indirectly for the htmllib.HTMLParser class). This has all the support for scanning over DOCTYPE declarations; it warrants having a base class since this is a fair amount of tedious code (since it's fairly strict), and should be in a separate module to avoid compiling many REs that are not used (which would happen if this were placed in either then sgmllib or HTMLParser module).
* Another comparison patch-up: comparing a type with a dynamic metatypeGuido van Rossum2001-09-241-0/+7
| | | | to one with a static metatype raised an obscure error.
* Add more tests showing the relationship between exceptions raised & caughtFred Drake2001-09-241-9/+64
| | | | and the information provided to the profiler. This stuff is a mess!
* Do the same thing to complex that I did to str: the rich comparisonGuido van Rossum2001-09-241-0/+15
| | | | | function returns NotImplemented when comparing objects whose tp_richcompare slot is not itself.
* StringIO patch #462596: let's [c]StringIO accept read buffers onMarc-André Lemburg2001-09-242-9/+27
| | | | input to .write() too.
* Change string comparison so that it applies even when one (or both)Guido van Rossum2001-09-241-6/+6
| | | | | arguments are subclasses of str, as long as they don't override rich comparison.
* Fix the baffler that Tim reported: sometimes the repr() of an objectGuido van Rossum2001-09-241-2/+2
| | | | | looks like <X object at ...>, sometimes it says <X instance at ...>. Make this uniformly say <X object at ...>.
* start of new config handling stuffSteven M. Gava2001-09-246-48/+468
|
* More work on class display:Tim Peters2001-09-241-43/+61
| | | | | | | | | + 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.
* Try to do for pydoc's GUI mode what the earlier checkin did for textTim Peters2001-09-241-9/+92
| | | | | | | | | | | | | | | | | | | | 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.
* Part of a partial solution to SF bugs 463378, 463381, 463383, 463384.Tim Peters2001-09-231-8/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Generalize file.writelines() to allow iterable objects.Tim Peters2001-09-231-0/+53
|
* The test data (mostly example messages) for the email package testBarry Warsaw2001-09-2316-0/+643
| | | | suite. Note that other tests can put input data in this directory.
* An extensive test suite for the email package.Barry Warsaw2001-09-231-0/+797
|
* The email package version 1.0, prototyped as mimelibBarry Warsaw2001-09-2312-0/+1302
| | | | | | <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).
* New function classify_class_attrs(). As a number of SF bug reportsTim Peters2001-09-232-0/+286
| | | | | | | | | | | | | | | | | | | 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).
* Make difflib.ndiff() and difflib.Differ.compare() generators. ThisTim Peters2001-09-221-53/+47
| | | | | restores the 2.1 ability of Tools/scripts/ndiff.py to start producing output before the entire comparison is complete.
* Add a function to compute a class's method resolution order. This isTim Peters2001-09-222-0/+38
| | | | | | 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.
* Since the most likely failure mode for an expected-output test is a changeTim Peters2001-09-221-15/+22
| | | | | | | 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.
* __iter__(): New method so that StringIO's can participate in theBarry Warsaw2001-09-221-0/+3
| | | | iterator protocol.
* Converted test_StringIO.py to use unittest, soBarry Warsaw2001-09-222-62/+71
| | | | | | | 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.
* Start of a test to make sure the profiler/tracer support in the coreFred Drake2001-09-221-0/+110
| | | | interpreter is reporting what we expect to see.
* Add the __getattr__ hook back. The rules are now:Guido van Rossum2001-09-211-5/+4
| | | | | | | - 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.
* reportdiff(): print a "plain diff" style diff.Guido van Rossum2001-09-211-4/+30
| | | | XXX This should really be a unified diff, but I can't be bothered.
* Oops. I didn't expect that some tests (test_cookie) have expectedGuido van Rossum2001-09-212-9/+3
| | | | | output *and* doctest stuff. Assuming the doctest stuff comes after the expected output, this fixes that.
* Change the way unexpected output is reported: rather than stopping atGuido van Rossum2001-09-212-94/+52
| | | | | | | | | | 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.
* Change the name of the __getattr__ special method for new-styleGuido van Rossum2001-09-212-7/+7
| | | | | | | | 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.
* Make these modules work when Python is compiled without Unicode support.Guido van Rossum2001-09-213-5/+18
|
* Add tests for repr() of strings containing string quotes as well.Guido van Rossum2001-09-211-0/+4
|
* Test basic functioning of unicode repr(). (If this breaks Jython,Guido van Rossum2001-09-211-0/+11
| | | | please let me know and we'll figure out how to fix the test.)
* Add a small test to verify that member and getset descriptors now haveGuido van Rossum2001-09-201-0/+8
| | | | docstrings (using file.closed and file.name as examples).
* Change testdescr.py to use the test_main() approach.Guido van Rossum2001-09-201-4/+4
|
* Change the PyUnit-based tests to use the test_main() approach. ThisFred Drake2001-09-2034-39/+229
| | | | | allows using the tests with unittest.py as a script. The tests will still run when run as a script themselves.
* Fix Unicode .join() method to raise a TypeError for sequenceMarc-André Lemburg2001-09-201-1/+0
| | | | | | | | | | 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.
* Update test output after the unicode() change.Marc-André Lemburg2001-09-201-0/+1
|
* Python part of the UTF-7 codec by Brian Quinlan.Marc-André Lemburg2001-09-201-0/+27
|
* Implement the changes proposed in patch #413333. unicode(obj) nowMarc-André Lemburg2001-09-201-0/+5
| | | | | works just like str(obj) in that it tries __str__/tp_str on the object in case it finds that the object is not a string or buffer.
* Patch #435971: UTF-7 codec by Brian Quinlan.Marc-André Lemburg2001-09-202-1/+32
|
* Patch #462635 by Andrew Kuchling correcting bugs in the newMarc-André Lemburg2001-09-205-11/+21
| | | | | codecs -- the self argument does matter for Python functions (it does not for C functions which most other codecs use).
* run_suite(): Oops, update a docstring.Barry Warsaw2001-09-201-1/+1
|
* run_suite(): Factor this out of run_unittest() for tests that buildBarry Warsaw2001-09-201-2/+7
| | | | | | | | their own test suite from a multitude of classes (like test_email.py will be doing). run_unittest(): Call run_suite() after making a suite from the testclass.
* Since inspect.isfunction(obj) is a precondition for callingTim Peters2001-09-201-6/+6
| | | | | | | | inspect.getargspec(obj), test isfunction() directly in pydoc.py instead of trying to indirectly deduce isfunction() in pydoc by virtue of failing a combination of other tests. This shouldn't have any visible effect, except perhaps to squash a TypeError death if there was some path thru this code that was inferring isfunction() by mistake.
* Ensure that isfunction(obj) and (the new) ismethoddescriptor(obj) neverTim Peters2001-09-201-5/+8
| | | | | both return true. This restores pydoc's ability to deduce argument lists for functions and methods coded in Python.
* After much thrashing, I believe this is a truly minimal patch to teachTim Peters2001-09-202-4/+27
| | | | | pydoc how to do something sensible with 2.2 descriptors. To see the difference, browse __builtin__ via pydoc before and after the patch.