Jeremy Hylton [Thu, 22 May 2003 18:11:20 +0000 (18:11 +0000)]
Backport fix for SF bug 692776.
Add a tp_new slot to function objects that handles the case of a
function requiring a closure. Put the function type in the new
module, rather than having a function new.function(). Add tests.
Barry Warsaw [Thu, 22 May 2003 17:36:54 +0000 (17:36 +0000)]
Link the dbm module against gdbm if it exists and if no earlier
library match was found. This fixes dbm on RedHat 9 and doesn't
appear (so far <wink>) to have any regressions on other *nixes.
Tim Peters [Wed, 21 May 2003 20:43:10 +0000 (20:43 +0000)]
PyType_Ready(): Complain if the type is a base type, and gc'able, and
tp_free is NULL or PyObject_Del at the end. Because it's a base type
it must call tp_free in its dealloc function, and because it's gc'able
it must not call PyObject_Del.
inherit_slots(): Don't inherit tp_free unless the type and its base
agree about whether they're gc'able. If the type is gc'able and the
base is not, and the base uses the default PyObject_Del for its
tp_free, give the type PyObject_GC_Del for its tp_free (the appropriate
default for a gc'able type).
cPickle.c: The Pickler and Unpickler types claim to be base classes
and gc'able, but their dealloc functions didn't call tp_free.
Repaired that. Also call PyType_Ready() on these typeobjects, so
that the correct (PyObject_GC_Del) default memory-freeing function
gets plugged into these types' tp_free slots.
Martin v. Löwis [Tue, 20 May 2003 06:16:55 +0000 (06:16 +0000)]
SF patch #497420 (Eduardo Pérez): ftplib: ftp anonymous password
Instead of sending the real user and host, use "anonymous@" (i.e. no
host name at all!) as the default anonymous FTP password. This avoids
privacy violations.
Tim Peters [Wed, 30 Apr 2003 19:24:59 +0000 (19:24 +0000)]
file_truncate(): Backported 2.3 code so that file.truncate(n) works on
Windows when n is too big to fit in a 32-bit int. This was a hole in
2.2's large file support on Windows, and turns out it's a bad hole at
least for ZODB.
SF bug #729096: getopt online documentation example improvement
A newbie found it difficult to translate the exampe into a
case that used only short options or long options but not both.
He tried to shorten the tuple search but forgot the trailing comma,
The appropriate pattern is an equality check.
Revised the example to point him in the right direction.
Barry Warsaw [Sun, 27 Apr 2003 04:00:01 +0000 (04:00 +0000)]
detect_modules(): On Redhat 9, building the ssl stuff eventually
includes krb5.h. Copy the krb5_h stanza from Python 2.3's setup.py
which seems to fix the problem.
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).