Tim Peters [Wed, 23 Apr 2003 20:14:12 +0000 (20:14 +0000)]
fsync(): Implemented for Windows, via calling MS _commit. This counts
as "a bug" because there's no other way in core Python to ensure that
bytes written are actually on disk. At least ZODB wants this guarantee,
for robustness against crashes.
Backport:
Fix SF bug #697220, string.strip implementation/doc mismatch
Attempt to make all the various string/unicode *strip methods the same.
* Doc - add doc for when functions were added
* UserString
* string/unicode object methods
* string module functions
'chars' is used for the last parameter everywhere.
Backport:
PyErr_NormalizeException(): in the type==NULL test, we should simply
return. Setting an exception can mess with the exception state, and
continuing is definitely wrong (since type is dereferenced later on).
Some code that calls this seems to be prepared for a NULL exception
type, so let's be safe rather than sorry and simply assume there's
nothing to normalize in this case.
Backport from trunk:
property_traverse() should also traverse into prop_doc -- there's no
typecheck that guarantees it's a string, and BTW string subclasses
could hide references.
Tim Peters [Tue, 8 Apr 2003 19:13:14 +0000 (19:13 +0000)]
More backporting of gc-vs-__del__ fixes. It should be fixed for instances
of classic classes now. Alas, new-style classes are still a problem, and
didn't need to be fixed in 2.3 (they were already immune in 2.3 due to the
new-in-2.3 tp_del slot).
Tim Peters [Tue, 8 Apr 2003 19:02:34 +0000 (19:02 +0000)]
Added private API function _PyInstance_Lookup(). This is part of
backporting fixes so that garbage collection doesn't have to trigger
execution of arbitrary Python code just to figure out whether
an object has a __del__ method.
Barry Warsaw [Fri, 4 Apr 2003 02:46:38 +0000 (02:46 +0000)]
Backporting:
revision 1.27
date: 2003/03/30 20:46:47; author: bwarsaw; state: Exp; lines: +3 -3
__unicode__(): Fix the logic for calculating whether to add a
separating space or not between encoded chunks. Closes SF bug
#710498.
Jeremy Hylton [Thu, 3 Apr 2003 23:02:29 +0000 (23:02 +0000)]
Fix memory corruption in garbage collection.
The move_finalizers() routine checks each object in the unreachable
list to see if it has a finalizer. If it does, it is moved to the
finalizers list. The collector checks by calling, effectively,
hasattr(obj, "__del__"). The hasattr() call can result in an
arbitrary amount of Python code being run, because it will invoke
getattr hooks on obj.
If a getattr() hook is run from move_finalizers(), it may end up
resurrecting or deallocating objects in the unreachable list. In
fact, it's possible that the hook causes the next object in the list
to be deallocated. That is, the object pointed to by gc->gc.gc_next
may be freed before has_finalizer() returns.
The problem with the previous revision is that it followed
gc->gc.gc_next before calling has_finalizer(). If has_finalizer()
gc->happened to deallocate the object FROM_GC(gc->gc.gc_next), then
the next time through the loop gc would point to freed memory. The
fix is to always follow the next pointer after calling
has_finalizer().
Note that Python 2.3 does not have this problem, because
has_finalizer() checks the tp_del slot and never runs Python code.
Tim, Barry, and I peed away the better part of two days tracking this
down.
Tim Peters [Mon, 31 Mar 2003 22:48:29 +0000 (22:48 +0000)]
This was failing on Windows, due to various attempts to delete files
that were still open. Made the tail end of the test look more like
the CVS head version.
Neal Norwitz [Sun, 30 Mar 2003 19:26:50 +0000 (19:26 +0000)]
Backport Patch 659834 checked in by GvR on 2002/12/30 16:25:38
Check for readline 2.2 features. This should make it possible to
compile readline.c again with GNU readline versions 2.0 or 2.1; this
ability was removed in readline.c rev. 2.49. Apparently the older
versions are still in widespread deployment on older Solaris
installations. With an older readline, completion behavior is subtly
different (a space is always added).
Neal Norwitz [Sat, 29 Mar 2003 22:25:18 +0000 (22:25 +0000)]
Backport Patch 659834 checked in by GvR on 2002/12/30 16:25:38
Check for readline 2.2 features. This should make it possible to
compile readline.c again with GNU readline versions 2.0 or 2.1; this
ability was removed in readline.c rev. 2.49. Apparently the older
versions are still in widespread deployment on older Solaris
installations. With an older readline, completion behavior is subtly
different (a space is always added).
Fred Drake [Thu, 20 Mar 2003 22:20:43 +0000 (22:20 +0000)]
- added example of using a comparison function with list.sort(), and
explained the construction of a [(key, value), ...] list as an
alternative
- backport additional notes on list use from Python 2.3 documentation;
mostly warnings about what not to rely on
Tim Peters [Thu, 20 Mar 2003 18:31:20 +0000 (18:31 +0000)]
SF bug 705836: struct.pack of floats in non-native endian order
pack_float, pack_double, save_float: All the routines for creating
IEEE-format packed representations of floats and doubles simply ignored
that rounding can (in rare cases) propagate out of a long string of
1 bits. At worst, the end-off carry can (by mistake) interfere with
the exponent value, and then unpacking yields a result wrong by a factor
of 2. In less severe cases, it can end up losing more low-order bits
than intended, or fail to catch overflow *caused* by rounding.
Thomas Wouters [Mon, 17 Mar 2003 11:34:43 +0000 (11:34 +0000)]
binascii_a2b_base64: Properly return an empty string if the input was all
invalid, rather than returning a string of random garbage of the
estimated result length. Closes SF patch #703471 by Hye-Shik Chang.
[Backport patch #649762] Fix for asynchat endless loop
When the null string is used as the terminator, it used to be the same
as None, meaning "collect all the data". In the current code, however, it
falls into an endless loop; this change reverts to the old behavior.
Fred Drake [Thu, 6 Mar 2003 16:27:58 +0000 (16:27 +0000)]
Backport patch from revision 2.80:
Fix memory leak: free memory storing the content model passed to the
ElementDeclHandler by Expat.
Fixes SF bug #676990.
Guido van Rossum [Mon, 24 Feb 2003 01:23:03 +0000 (01:23 +0000)]
Backport:
Fix from SF patch #633359 by Greg Chapman for SF bug #610299:
The problem is in sre_compile.py: the call to
_compile_charset near the end of _compile_info forgets to
pass in the flags, so that the info charset is not compiled
with re.U. (The info charset is used when searching to find
the first character at which a match could start; it is not
generated for patterns beginning with a repeat like '\w{1}'.)
Neal Norwitz [Sun, 23 Feb 2003 23:34:37 +0000 (23:34 +0000)]
Backport relevant portions of:
Fix SF bug #691793, Python 2.3a2 build fails on Tru64
Need to make sure that preprocessor directives start in first column.
This means we can't indent code which has preprocessor directives,
nor have a space between [ #include for example.
Backport 1.38:
Fix an old bug in poll(). When a signal is handled while we're
blocked in select(), this will raise select.error with errno set to
EINTR. The except clauses correctly ignores this error, but the rest
of the logic will then call read() for all objects in select's *input*
list of read file descriptors. Then when an object's read_handler()
is naive, it will call recv() on its socket, which will raise an
IOError, and then asyncore decides to close the socket. To fix this,
we simply return in this case.
Backport candidate.
Guido van Rossum [Wed, 19 Feb 2003 03:52:47 +0000 (03:52 +0000)]
Backport of rev 2.199 from trunk.
PyObject_Generic{Get,Set}Attr:
Don't access tp_descr_{get,set} of a descriptor without checking the
flag bits of the descriptor's type. While we know that the main type
(the type of the object whose attribute is being accessed) has all the
right flag bits (or else PyObject_Generic{Get,Set}Attr wouldn't be
called), we don't know that for its class attributes!
Guido van Rossum [Wed, 19 Feb 2003 03:21:21 +0000 (03:21 +0000)]
Backport of rev 2.199 from trunk.
PyObject_Generic{Get,Set}Attr:
Don't access tp_descr_{get,set} of a descriptor without checking the
flag bits of the descriptor's type. While we know that the main type
(the type of the object whose attribute is being accessed) has all the
right flag bits (or else PyObject_Generic{Get,Set}Attr wouldn't be
called), we don't know that for its class attributes!
Guido van Rossum [Thu, 13 Feb 2003 17:06:02 +0000 (17:06 +0000)]
Backport 2.217 and 2.218:
Provide access to the import lock, fixing SF bug #580952. This is
mostly from SF patch #683257, but I had to change unlock_import() to
return an error value to avoid fatal error.
Fred Drake [Tue, 4 Feb 2003 15:13:25 +0000 (15:13 +0000)]
Update to better reflect the usage of struct_time instances throughout;
continuing to call these "time tuples" is misleading at best.
Closes SF bug #671731; backported from rev 1.55.
Neal Norwitz [Sun, 2 Feb 2003 19:59:59 +0000 (19:59 +0000)]
backport:
revision 2.196
date: 2002/12/07 21:39:16; author: tim_one; state: Exp; lines: +27 -28
slot_nb_nonzero(): Another leak uncovered by the sandbox datetime
tests. I found the logic too confusing to follow here, so rewrote more
than was likely absolutely necessary.
Neal Norwitz [Sun, 2 Feb 2003 19:37:32 +0000 (19:37 +0000)]
backport:
revision 2.164
date: 2002/10/29 18:36:40; author: gvanrossum; state: Exp; lines: +12 -13
Since properties are supported here, is possible that
instance_getattr2() raises an exception. Fix all code that made this
assumption.