Tim Peters [Tue, 27 Nov 2001 23:29:29 +0000 (23:29 +0000)]
SF bug #483469: crash on unbounded recursion in __del__.
PyEval_EvalCodeEx(): increment tstate->recursion_depth around the
decref of the frame, because the C stack for this call is still in
use and the decref can lead to __del__ methods getting called.
While this gives tstate->recursion_depth a value proportional to the
depth of the C stack (instead of a small constant no matter how
deeply __del__s recurse), it's not enough to stop the reported crash
when using the default recursion limit on Windows.
Tim Peters [Tue, 27 Nov 2001 20:30:42 +0000 (20:30 +0000)]
SF bug 485175: buffer overflow in traceback.c.
Bugfix candidate.
tb_displayline(): the sprintf format was choking off the file name, but
used plain %s for the function name (which can be arbitrarily long).
Limit both to 500 chars max.
Barry Warsaw [Tue, 27 Nov 2001 07:12:35 +0000 (07:12 +0000)]
test_formatdate(): Integrating Jack's 22b2 branch fix for Mac epoch:
More changes to the formatdate epoch test: the Mac epoch is in
localtime, so east of GMT it falls in 1903:-( Changed the test to
obtain the epoch in both local time and GMT, and do the right
thing in the comparisons. As a sanity measure also check that
day/month is Jan 1.
Tim Peters [Sun, 25 Nov 2001 21:12:43 +0000 (21:12 +0000)]
SF patch 483059: Avoid use of eval() in random.py, from Finn Bock.
_verify(): Pass in the values of globals insted of eval()ing their
names. The use of eval() was obscure and unnecessary, and the patch
claimed random.py couldn't be used in Jython applets because of it.
Guido van Rossum [Sat, 24 Nov 2001 21:04:31 +0000 (21:04 +0000)]
_reduce():
- Fix for SF bug #482752: __getstate__ & __setstate__ ignored (by Anon.)
In fact, only __getstate__ isn't recognized. This fixes that.
- Separately, the test for base.__flags__ & _HEAPTYPE raised an
AttributeError exception when a classic class was amongst the
bases. Fixed this with a hasattr() bandaid (classic classes never
qualify as the "hard" base class anyway, which is what the code is
trying to find).
Guido van Rossum [Sat, 24 Nov 2001 18:24:47 +0000 (18:24 +0000)]
PyObject_GetItem(), PyObject_SetItem(), PyObject_DelItem(): Fix a few
confusing error messages. If a new-style class has no sequence or
mapping behavior, attempting to use the indexing notation with a
non-integer key would complain that the sequence index must be an
integer, rather than complaining that the operation is not supported.
Barry Warsaw [Mon, 19 Nov 2001 18:36:43 +0000 (18:36 +0000)]
formatdate(): Jason Mastaler correctly points out that divmod with a
negative modulus won't return the right values. So always do positive
modulus on an absolute value and twiddle the sign as appropriate after
the fact.
Barry Warsaw [Mon, 19 Nov 2001 16:31:06 +0000 (16:31 +0000)]
test_formatdate(), test_formatdate_zoneoffsets(): Two changes. First,
use the correct way to test for epoch, by looking at the year
component of gmtime(0). Add clause for Unix epoch and Mac epoch (Tim,
what is Windows epoch?).
Also, get rid of the strptime() test, it was way too problematic given
that strptime() is missing on many platforms and issues with locales.
Instead, simply test that formatdate() gets the numeric timezone
calculation correct for the altzone and timezone.
Barry Warsaw [Mon, 19 Nov 2001 16:28:07 +0000 (16:28 +0000)]
formatdate(): The calculation of the minutes part of the zone was
incorrect for "uneven" timezones. This algorithm should work for even
timezones (e.g. America/New_York) and uneven timezones (e.g.
Australia/Adelaide and America/St_Johns).
Fred Drake [Sun, 18 Nov 2001 04:58:28 +0000 (04:58 +0000)]
Clarified a couple of issues for the startElement*() handlers:
- the attrs value may be re-used by the parser, so the implementation
cannot rely on owning the object.
- an element with no namespace encountered in namespace mode will have a URI
of None, not "" (startElementNS() only).
Fred Drake [Sat, 17 Nov 2001 06:50:42 +0000 (06:50 +0000)]
Exhibit good form in C code: always provide docstrings in method tables, and
always fill in all slots of table entries.
Fixed a few minor markup errors.
Fred Drake [Sat, 17 Nov 2001 06:30:20 +0000 (06:30 +0000)]
Update to use more modern calling conventions; also avoid a magic number
in the function table. Add a docstring for the function as well, since
examples should show good form.
Barry Warsaw [Fri, 16 Nov 2001 22:16:04 +0000 (22:16 +0000)]
Add a clarification that the email package always deals in native line
endings, and that it is smtplib's job to convert those to RFC 2821
line endings when sending the message.
Fred Drake [Fri, 16 Nov 2001 06:02:55 +0000 (06:02 +0000)]
Clean up some markup a little bit more. Make this work with the PDF format,
which is a little more strict than the other formats on some things (fixable,
but not tonight).
Fred Drake [Fri, 16 Nov 2001 02:52:57 +0000 (02:52 +0000)]
Fix parsing of parameters from a URL; urlparse() did not check that it only
split parameters from the last path segment. Introduces two new functions,
urlsplit() and urlunsplit(), that do the simpler job of splitting the URL
without monkeying around with the parameters field, since that was not being
handled properly.
This closes bug #478038.
Barry Warsaw [Thu, 15 Nov 2001 23:45:26 +0000 (23:45 +0000)]
A change to sync with pickle.py:
find_class(): We no longer mask all exceptions[1] by transforming them
into SystemError. The latter is definitely not the right thing to do,
so we let any exceptions that occur in the PyObject_GetAttr() call to
simply propagate up if they occur.
[1] Note that pickle only masked ImportError, KeyError, and
AttributeError, but cPickle masked all exceptions.
Barry Warsaw [Thu, 15 Nov 2001 23:42:58 +0000 (23:42 +0000)]
Two changes:
load_inst(): Implement the security hook that cPickle already had.
When unpickling callables which are not classes, we look to see if the
object has an attribute __safe_for_unpickling__. If this exists and
has a true value, then we can call it to create the unpickled object.
Otherwise we raise an UnpicklingError.
find_class(): We no longer mask ImportError, KeyError, and
AttributeError by transforming them into SystemError. The latter is
definitely not the right thing to do, so we let the former three
exceptions simply propagate up if they occur, i.e. we remove the
try/except!
Barry Warsaw [Thu, 15 Nov 2001 23:39:07 +0000 (23:39 +0000)]
A massive rewrite affecting both the pickle and cPickle module
documentation. This addresses previously undocumented parts of the
public interfaces, the differences between pickle and cPickle,
security concerns, and on and on.
Guido van Rossum [Thu, 15 Nov 2001 20:27:54 +0000 (20:27 +0000)]
Correct the description of mixed multiple inheritance: the code
special-cases classic classes, it doesn't do anything about other
cases where different metaclasses are involved (except for the trivial
case where one metaclass is a subclass of the others). Also note that
it's metaclass, not metatype.
Tim Peters [Wed, 14 Nov 2001 23:32:33 +0000 (23:32 +0000)]
Changing diapers reminded Guido that he wanted to allow for some measure
of multiple inheritance from a mix of new- and classic-style classes.
This is his patch, plus a start at some test cases from me. Will check
in more, plus a NEWS blurb, later tonight.
Jack Jansen [Wed, 14 Nov 2001 10:59:57 +0000 (10:59 +0000)]
OSX tests used specific version numbers to test for new features and
used the default Darwin/* for the old code. Reversed those tests so
that compatibility code is in a switch leg with a specific version and
newer systems take the default leg.
This should allow Python to build on OSX 10.1.1 (which jumps from Darwin/1.4
to Darwin/5.1 due to a new numbering scheme).
Tim Peters [Tue, 13 Nov 2001 23:11:19 +0000 (23:11 +0000)]
CVS patch #477161: New "access" keyword for mmap, from Jay T Miller.
This gives mmap() on Windows the ability to create read-only, write-
through and copy-on-write mmaps. A new keyword argument is introduced
because the mmap() signatures diverged between Windows and Unix, so
while they (now) both support this functionality, there wasn't a way to
spell it in a common way without introducing a new spelling gimmick.
The old spellings are still accepted, so there isn't a backward-
compatibility issue here.
Barry Warsaw [Tue, 13 Nov 2001 20:16:52 +0000 (20:16 +0000)]
Committing the second part of patch #480902, an improved test suite
for dumbdbm.py, by Skip Montanaro. The first half of Skip's patch has
been postponed until Py2.3 since it adds new features.
Jack Jansen [Sat, 10 Nov 2001 23:21:55 +0000 (23:21 +0000)]
Add the MSL C library to the set of standard libraries
linked against. Most, but not all, of it is included in
PythonCore, but extensions may want to use some of
the routines not included. Fixes a bug reported by
Tom Loredo.