Martin v. Löwis [Sun, 23 Sep 2001 10:20:10 +0000 (10:20 +0000)]
Reactivate participation of expat parsers in GC. Fixes bug #462710.
Tim Peters [Sun, 23 Sep 2001 07:02:29 +0000 (07:02 +0000)]
Install the new Lib/email pkg.
Create & populate the new Lib/test/data directory.
Tim Peters [Sun, 23 Sep 2001 04:06:05 +0000 (04:06 +0000)]
Generalize file.writelines() to allow iterable objects.
Barry Warsaw [Sun, 23 Sep 2001 03:19:33 +0000 (03:19 +0000)]
The test data (mostly example messages) for the email package test
suite. Note that other tests can put input data in this directory.
Barry Warsaw [Sun, 23 Sep 2001 03:18:13 +0000 (03:18 +0000)]
An extensive test suite for the email package.
Barry Warsaw [Sun, 23 Sep 2001 03:17:28 +0000 (03:17 +0000)]
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).
Fred Drake [Sun, 23 Sep 2001 02:05:26 +0000 (02:05 +0000)]
Added API information for the PyCallIter_*() and PySeqIter_*() functions.
Added signatures for some new PyType_*() functions.
Tim Peters [Sun, 23 Sep 2001 02:00:29 +0000 (02:00 +0000)]
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).
Tim Peters [Sat, 22 Sep 2001 21:59:18 +0000 (21:59 +0000)]
Fix restore (difflib.restore() became a generator too).
Tim Peters [Sat, 22 Sep 2001 21:30:22 +0000 (21:30 +0000)]
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.
Guido van Rossum [Sat, 22 Sep 2001 17:10:44 +0000 (17:10 +0000)]
Add note about __getattribute__.
Tim Peters [Sat, 22 Sep 2001 06:10:55 +0000 (06:10 +0000)]
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.
Tim Peters [Sat, 22 Sep 2001 05:31:03 +0000 (05:31 +0000)]
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.
Barry Warsaw [Sat, 22 Sep 2001 04:44:21 +0000 (04:44 +0000)]
{String,cString}IO.StringIO's support iteration.
Barry Warsaw [Sat, 22 Sep 2001 04:36:49 +0000 (04:36 +0000)]
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()
Barry Warsaw [Sat, 22 Sep 2001 04:34:54 +0000 (04:34 +0000)]
__iter__(): New method so that StringIO's can participate in the
iterator protocol.
Fred Drake [Sat, 22 Sep 2001 04:34:48 +0000 (04:34 +0000)]
Note that files are iterable; describe what the iterator returns.
This closes SF bug #463738.
Barry Warsaw [Sat, 22 Sep 2001 04:33:47 +0000 (04:33 +0000)]
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.
Fred Drake [Sat, 22 Sep 2001 04:28:19 +0000 (04:28 +0000)]
Start of a test to make sure the profiler/tracer support in the core
interpreter is reporting what we expect to see.
Guido van Rossum [Fri, 21 Sep 2001 21:24:49 +0000 (21:24 +0000)]
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.
Fred Drake [Fri, 21 Sep 2001 21:18:16 +0000 (21:18 +0000)]
Bump version number.
Fred Drake [Fri, 21 Sep 2001 21:12:30 +0000 (21:12 +0000)]
Added reference to Tutorial section on user-defined exceptions for
information on defining new exceptions.
This closes SF bug #443559.
Fred Drake [Fri, 21 Sep 2001 21:10:05 +0000 (21:10 +0000)]
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.
Guido van Rossum [Fri, 21 Sep 2001 21:06:22 +0000 (21:06 +0000)]
reportdiff(): print a "plain diff" style diff.
XXX This should really be a unified diff, but I can't be bothered.
Guido van Rossum [Fri, 21 Sep 2001 20:45:44 +0000 (20:45 +0000)]
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.
Guido van Rossum [Fri, 21 Sep 2001 20:31:52 +0000 (20:31 +0000)]
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.
Guido van Rossum [Fri, 21 Sep 2001 19:29:08 +0000 (19:29 +0000)]
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.
Guido van Rossum [Fri, 21 Sep 2001 19:22:34 +0000 (19:22 +0000)]
Make these modules work when Python is compiled without Unicode support.
Guido van Rossum [Fri, 21 Sep 2001 15:46:41 +0000 (15:46 +0000)]
Add tests for repr() of strings containing string quotes as well.
Guido van Rossum [Fri, 21 Sep 2001 15:38:17 +0000 (15:38 +0000)]
Fix a bug in rendering of \\ by repr() -- it rendered as \\\ instead
of \\.
Guido van Rossum [Fri, 21 Sep 2001 15:36:41 +0000 (15:36 +0000)]
Test basic functioning of unicode repr(). (If this breaks Jython,
please let me know and we'll figure out how to fix the test.)
Guido van Rossum [Thu, 20 Sep 2001 21:49:53 +0000 (21:49 +0000)]
Add a small test to verify that member and getset descriptors now have
docstrings (using file.closed and file.name as examples).
Guido van Rossum [Thu, 20 Sep 2001 21:45:26 +0000 (21:45 +0000)]
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.
Guido van Rossum [Thu, 20 Sep 2001 21:39:07 +0000 (21:39 +0000)]
Change testdescr.py to use the test_main() approach.
Fred Drake [Thu, 20 Sep 2001 21:33:42 +0000 (21:33 +0000)]
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.
Guido van Rossum [Thu, 20 Sep 2001 20:46:19 +0000 (20:46 +0000)]
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.
Fred Drake [Thu, 20 Sep 2001 20:43:28 +0000 (20:43 +0000)]
Fill in a few more descriptions for xml.parsers.expat.
Tim Peters [Thu, 20 Sep 2001 19:55:29 +0000 (19:55 +0000)]
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().
Fred Drake [Thu, 20 Sep 2001 19:18:52 +0000 (19:18 +0000)]
Document all the Py*_CheckExact() functions.
Document many more of the PyLong_{As,From}*() functions.
Guido van Rossum [Thu, 20 Sep 2001 19:18:30 +0000 (19:18 +0000)]
PyLocale_setlocale(): silence compiler warning about free() of a const
char *.
Marc-André Lemburg [Thu, 20 Sep 2001 17:22:58 +0000 (17:22 +0000)]
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.
Marc-André Lemburg [Thu, 20 Sep 2001 16:37:23 +0000 (16:37 +0000)]
Update test output after the unicode() change.
Jeremy Hylton [Thu, 20 Sep 2001 15:27:30 +0000 (15:27 +0000)]
Update description of Tools/compiler
Jeremy Hylton [Thu, 20 Sep 2001 15:02:27 +0000 (15:02 +0000)]
Remove setup.py, unnecessary since compiler package is the std
library.
Update README.
Jeremy Hylton [Thu, 20 Sep 2001 14:59:00 +0000 (14:59 +0000)]
Moved to Tools/compiler along with astgen.py
Guido van Rossum [Thu, 20 Sep 2001 13:38:22 +0000 (13:38 +0000)]
_PyObject_GetDictPtr(): when the offset is negative, always align --
we can't trust that tp_basicsize is aligned. Fixes SF bug #462848.
Marc-André Lemburg [Thu, 20 Sep 2001 12:59:37 +0000 (12:59 +0000)]
Note about enhancements to unicode().
Marc-André Lemburg [Thu, 20 Sep 2001 12:56:14 +0000 (12:56 +0000)]
Python part of the UTF-7 codec by Brian Quinlan.
Marc-André Lemburg [Thu, 20 Sep 2001 12:53:16 +0000 (12:53 +0000)]
Implement the changes proposed in patch #413333. unicode(obj) now
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.
Marc-André Lemburg [Thu, 20 Sep 2001 10:35:46 +0000 (10:35 +0000)]
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg [Thu, 20 Sep 2001 10:33:38 +0000 (10:33 +0000)]
Patch #462635 by Andrew Kuchling correcting bugs in the new
codecs -- the self argument does matter for Python functions (it
does not for C functions which most other codecs use).
Tim Peters [Thu, 20 Sep 2001 07:55:22 +0000 (07:55 +0000)]
SF bug [#463093] File methods need doc strings.
Now they don't.
Barry Warsaw [Thu, 20 Sep 2001 06:31:22 +0000 (06:31 +0000)]
run_suite(): Oops, update a docstring.
Barry Warsaw [Thu, 20 Sep 2001 06:30:41 +0000 (06:30 +0000)]
run_suite(): Factor this out of run_unittest() for tests that build
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.
Tim Peters [Thu, 20 Sep 2001 06:08:24 +0000 (06:08 +0000)]
Since inspect.isfunction(obj) is a precondition for calling
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.
Tim Peters [Thu, 20 Sep 2001 05:47:55 +0000 (05:47 +0000)]
Ensure that isfunction(obj) and (the new) ismethoddescriptor(obj) never
both return true. This restores pydoc's ability to deduce argument lists
for functions and methods coded in Python.
Guido van Rossum [Thu, 20 Sep 2001 05:30:24 +0000 (05:30 +0000)]
News about compiler and pydoc.
Guido van Rossum [Thu, 20 Sep 2001 05:27:24 +0000 (05:27 +0000)]
AFAICT pydoc/inspect do the right thing again.
Tim Peters [Thu, 20 Sep 2001 05:13:38 +0000 (05:13 +0000)]
After much thrashing, I believe this is a truly minimal patch to teach
pydoc how to do something sensible with 2.2 descriptors. To see the
difference, browse __builtin__ via pydoc before and after the patch.
Tim Peters [Thu, 20 Sep 2001 04:09:39 +0000 (04:09 +0000)]
Install the compiler package under Lib.
Jeremy Hylton [Thu, 20 Sep 2001 01:27:40 +0000 (01:27 +0000)]
The compiler package is now part of the standard library.
Remove all these files. All except astgen.py are moved to Lib/compiler.
Martin v. Löwis [Wed, 19 Sep 2001 17:31:47 +0000 (17:31 +0000)]
Patch #461321: Support None as a timeout in poll2 and poll3.
Martin v. Löwis [Wed, 19 Sep 2001 13:47:32 +0000 (13:47 +0000)]
Patch #462849: Pass Unicode objects to file's .write method.
Guido van Rossum [Wed, 19 Sep 2001 13:28:25 +0000 (13:28 +0000)]
Keep tabnanny happy.
Marc-André Lemburg [Wed, 19 Sep 2001 11:52:07 +0000 (11:52 +0000)]
Fixed search function error reporting in the encodings package
__init__.py module to raise errors which can be catched as LookupErrors
as well as SystemErrors.
Modified the error messages to include more information about the
failing module.
Marc-André Lemburg [Wed, 19 Sep 2001 11:33:31 +0000 (11:33 +0000)]
Docs and News item for the codecs.py additions.
Marc-André Lemburg [Wed, 19 Sep 2001 11:24:48 +0000 (11:24 +0000)]
Added new helpers for easy access to codecs. Docs will follow.
Marc-André Lemburg [Wed, 19 Sep 2001 11:21:03 +0000 (11:21 +0000)]
Fix for bug #462737.
Martin v. Löwis [Wed, 19 Sep 2001 10:37:50 +0000 (10:37 +0000)]
Include ctype.h after Python.h.
Martin v. Löwis [Wed, 19 Sep 2001 09:55:09 +0000 (09:55 +0000)]
Patch to bug #461753: Allow None in ExternalEntityParserCreate.
Martin v. Löwis [Wed, 19 Sep 2001 09:08:19 +0000 (09:08 +0000)]
Patch to bug #461754: CDATA should not undergo entity subst.
Guido van Rossum [Wed, 19 Sep 2001 01:25:16 +0000 (01:25 +0000)]
Add additional coercion support for "self subtypes" to int, long,
float (compare the recent checkin to complex). Added tests for these.
Guido van Rossum [Wed, 19 Sep 2001 01:16:16 +0000 (01:16 +0000)]
Enable two checks for comparing a complex to a complex subtype
instance.
Split a string comparison test in two halves, replacing "a==b==a" with
separate tests for a==b and b==a. (Reason: while experimenting, this
test failed, and I wanted to know if it was the first or the second ==
operator that failed.)
Guido van Rossum [Wed, 19 Sep 2001 01:13:10 +0000 (01:13 +0000)]
complex_coerce(): add explicit PyComplex_Check() test. Previously,
complex_coerce() would never be called with a complex argument,
because PyNumber_Coerce[Ex] doesn't bother calling the type's coercion
method if the values already have the same type. But now, of course,
it's possible to pass an instance of a complex *subtype*, and those
must be accepted.
Tim Peters [Tue, 18 Sep 2001 21:24:18 +0000 (21:24 +0000)]
Enable some comparison tests that failed before. Still having problems
with subsclasses of complex and string.
Guido van Rossum [Tue, 18 Sep 2001 21:06:04 +0000 (21:06 +0000)]
Add a similar test for rich comparisons.
Fredrik Lundh [Tue, 18 Sep 2001 20:55:24 +0000 (20:55 +0000)]
fixed #449964: sre.sub raises an exception if the template contains a
\g<x> group reference followed by a character escape
(also restructured a few things on the way to fixing #449000)
Guido van Rossum [Tue, 18 Sep 2001 20:38:53 +0000 (20:38 +0000)]
Hopefully fix 3-way comparisons. This unfortunately adds yet another
hack, and it's even more disgusting than a PyInstance_Check() call.
If the tp_compare slot is the slot used for overrides in Python,
it's always called.
Add some tests that show what should work too.
Guido van Rossum [Tue, 18 Sep 2001 20:34:19 +0000 (20:34 +0000)]
Get rid of a superfluous space after "--" in the message printed for a
skipped test -- the print command already supplies a space.
Andrew M. Kuchling [Tue, 18 Sep 2001 20:32:13 +0000 (20:32 +0000)]
[Patch #462258] On Cygwin, don't build Tkinter unless the X header files
can be found.
Andrew M. Kuchling [Tue, 18 Sep 2001 20:29:48 +0000 (20:29 +0000)]
Fix typo in comment
Martin v. Löwis [Tue, 18 Sep 2001 20:23:28 +0000 (20:23 +0000)]
Properly repr classes without module names.
Guido van Rossum [Tue, 18 Sep 2001 20:04:26 +0000 (20:04 +0000)]
Test for the safety check in wrap_cmpfunc().
Guido van Rossum [Tue, 18 Sep 2001 20:03:57 +0000 (20:03 +0000)]
wrap_cmpfunc(): added a safety check for the __cmp__ wrapper. We can
only safely call a type's tp_compare slot if the second argument is
also an instance of the same type. I hate to think what
e.g. int_compare() would do with a second argument that's a float!
Fredrik Lundh [Tue, 18 Sep 2001 18:47:09 +0000 (18:47 +0000)]
an SRE bugfix a day keeps Guido away...
#462270: sub-tle difference between pre.sub and sre.sub. PRE ignored
an empty match at the previous location, SRE didn't.
also synced with Secret Labs "sreopen" codebase.
Fred Drake [Tue, 18 Sep 2001 17:58:20 +0000 (17:58 +0000)]
Fix minor usage and consistency nits.
Guido van Rossum [Tue, 18 Sep 2001 15:21:04 +0000 (15:21 +0000)]
All the news that fits, we print.
(Went through the logs looking for nuggets. This is what I found.)
Guido van Rossum [Tue, 18 Sep 2001 14:34:06 +0000 (14:34 +0000)]
SF bug #417176 (Martijn Pieters): MultiFile.read() includes CRLF
boundary.
Fixed by keeping a readahead buffer containing the next line.
XXX We have no test suite for this. Maybe the new email package will
help?
Guido van Rossum [Tue, 18 Sep 2001 13:33:01 +0000 (13:33 +0000)]
softspace(): be prepared to catch AttributeError as well as TypeError
upon attempted attribute assignment. Caught by MWH, SF bug #462522.
Tim Peters [Tue, 18 Sep 2001 05:40:24 +0000 (05:40 +0000)]
This module didn't work at all anymore -- blew up with AttributeError
on file.__methods__. Since the docs say "This module will become obsolete
in a future release", this is just a quick hack to stop it from blowing
up. If you care about this module, test it! It doesn't make much sense
on Windows.
Guido van Rossum [Tue, 18 Sep 2001 03:55:22 +0000 (03:55 +0000)]
Undo some (but not all) of the more lenient acceptance of
(AttributeError, TypeError) -- the leniency wasn't needed everywhere.
Guido van Rossum [Tue, 18 Sep 2001 03:53:24 +0000 (03:53 +0000)]
Redo the PyMethod attributes using a dir()-friendly approach, creating
descriptors for each attribute. The getattr() implementation is
similar to PyObject_GenericGetAttr(), but delegates to im_self instead
of looking in __dict__; I couldn't do this as a wrapper around
PyObject_GenericGetAttr().
XXX A problem here is that this is a case of *delegation*. dir()
doesn't see exactly the same attributes that are actually defined;
e.g. if the delegate is a Python function object, it supports
attributes like func_code etc., but these are not visible to dir(); on
the other hand, dynamic function attributes (stored in the function's
__dict__) *are* visible to dir(). Maybe we need a mechanism to tell
dir() about the delegation mechanism? I vaguely recall seeing a
request in the newsgroup for a more formal definition of attribute
delegation too. Sigh, time for a new PEP.
Guido van Rossum [Tue, 18 Sep 2001 03:28:54 +0000 (03:28 +0000)]
- Some tests that check that assignments are not allowed expect this
to raise TypeError. In practice, a disallowed attribute assignment
can raise either TypeError or AttributeError (and it's unclear which
is better). So allow either. (Yes, this is in anticipation of a
code change that switches the exception raised. :-)
- Add a utility function, cantset(), which verifies that setting a
particular attribute to a given value is disallowed, and also that
deleting that same attribute is disallowed. Use this in the
test_func_*() tests.
- Add a new set of tests that test conformance of various instance
method attributes. (Also in anticipation of code that changes their
implementation.)
Guido van Rossum [Tue, 18 Sep 2001 02:40:21 +0000 (02:40 +0000)]
Sort the headers in PYTHON_HEADERS alphabetically. Add
structmember.h, which was missing (and caused me a snide comment by
Tim when he fixed something I missed because of the missed dependency
:-).
Tim Peters [Tue, 18 Sep 2001 02:26:39 +0000 (02:26 +0000)]
Whitespace normalization.
Tim Peters [Tue, 18 Sep 2001 02:18:57 +0000 (02:18 +0000)]
Make test_socketserver require the network resource.
Add it back to the list of tests we expect to skip on Windows.
Tim Peters [Tue, 18 Sep 2001 00:24:10 +0000 (00:24 +0000)]
I don't expect test_socketserver to get skipped on Windows anymore.
Tim Peters [Tue, 18 Sep 2001 00:23:33 +0000 (00:23 +0000)]
type_new(): Didn't compile anymore, due to change in struct memberlist
definition. Guido, what else did you forget to check in <wink>?
Tim Peters [Mon, 17 Sep 2001 23:56:20 +0000 (23:56 +0000)]
Rework akin to test_threaded_import, so that this can run under regrtest.
Also raise TestSkipped (intead of appearing to fail) if the import lock
is held.
Guido van Rossum [Mon, 17 Sep 2001 23:46:56 +0000 (23:46 +0000)]
Rewrite function attributes to use the generic routines properly.
This uses the new "restricted" feature of structmember, and getset
descriptors for some of the type checks.