Commit Graph

2496 Commits

Author SHA1 Message Date
Jeremy Hylton
d8136b500a Backport fixes to make more types collectable.
classmethod, staticmethod, cPickle.Pickler, cPickle.UNpickler
2003-05-09 18:29:21 +00:00
Tim Peters
c18cc56c21 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.
2003-04-23 20:14:12 +00:00
Fred Drake
d065a13a96 Backport reference leak fix from HEAD revision 1.79. 2003-04-09 18:19:24 +00:00
Tim Peters
8998a81937 Fixed the gc-vs-__del__ bugs for new-style classes. That's it for this one. 2003-04-08 20:33:05 +00:00
Tim Peters
539afe0d84 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).
2003-04-08 19:13:14 +00:00
Jeremy Hylton
f95350079c 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.
2003-04-03 23:02:29 +00:00
Martin v. Löwis
fa8b672c2a Patch #695250: Suppress COPYRIGHT if site.py is not read. Fixes #672614. 2003-03-30 17:00:58 +00:00
Neal Norwitz
80288f4f85 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).
2003-03-29 22:25:18 +00:00
Tim Peters
58d23ae9a9 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.
2003-03-20 18:31:20 +00:00
Thomas Wouters
c5f77780f0 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 from 2.3.
2003-03-17 11:34:43 +00:00
Fred Drake
2c3d827248 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.
2003-03-06 16:27:58 +00:00
Neal Norwitz
5eb8227235 get_completer() takes no args 2003-03-01 15:19:49 +00:00
Guido van Rossum
e0cf01371f - Backported SF patch #676342: after using pdb, the readline command
completion was botched.
2003-03-01 02:14:53 +00:00
Neal Norwitz
9aa5027699 Backport: Add more missing PyErr_NoMemory() after failled memory allocs 2003-02-11 23:19:35 +00:00
Tim Peters
ea57ec8169 SF bug 684667: Modules/selectmodule.c returns NULL without exception set.
Backport of fix from head.
2003-02-11 18:05:44 +00:00
Neal Norwitz
c31c0dfba3 Partial backport for changes to fix SF bug #678518 (assert & global). 2003-02-10 01:57:51 +00:00
Neal Norwitz
909be5a7f4 SF patch #682514, mmapmodule.c write fix for LP64 executables
Make length an int so we get the right value from
PyArg_ParseTuple(args, "s#", &str, &length)
2003-02-07 19:46:44 +00:00
Neal Norwitz
887ed5e2a9 backport:
revision 2.75
date: 2003/01/29 14:20:22;  author: mwh;  state: Exp;  lines: +2 -0
Teach the parsermodule about floor division.  Fixes

[ 676521 ] parser module validation failure
2003-02-02 19:34:14 +00:00
Neal Norwitz
583b86bd2c Backport SF # 669553, fix memory (ref) leaks 2003-01-19 15:48:38 +00:00
Neal Norwitz
3813a2131d backport:
SF #665913, Fix mmap module core dump with unix

Closing an mmap'ed file (calling munmap) twice on Solaris caused a core dump.
2003-01-10 21:02:41 +00:00
Guido van Rossum
e310b12978 Backport 2.58 from trunk (minus the cleanup):
Fix from Michael Stone for SF bug #660476 and #513033 (bogus thread
state swaps in readline).
2003-01-07 20:40:15 +00:00
Neal Norwitz
137084b610 Fix SF # 640557, '64-bit' systems and the dbm module
datum.dsize can apparently be long on some systems.
Ensure we pass an int* to PyArg_Parse("s#"), not &datum.dsize
2002-11-22 23:29:47 +00:00
Neal Norwitz
116a5c43a3 Fix SF # 505427, socket module fails to build on HPUX10
h_errno is not defined on HPUX with the 2.2 build env't
(ie, _XOPEN_SOURCE_EXTENDED is not defined)
2002-11-14 02:22:34 +00:00
Neal Norwitz
ed650c12d9 Backport last checkin:
SF #633013, Fix NIS causing interpreter core dump

Prevent the lengths passed to PyString_FromStringAndSize()
from being negative in some cases.
2002-11-04 23:40:47 +00:00
Neal Norwitz
6db1283992 Backport 2.34. SF #621948, update docstring for md5 by David M. Cooke 2002-10-11 21:55:13 +00:00