1376 Commits

Author SHA1 Message Date
Michael W. Hudson
e99c99389c backport tim_one's checkin of
revision 2.55 of complexobject.c

SF bug 533198:  Complex power underflow raises exception.
Konrad was too kind.  Not only did it raise an exception, the specific
exception it raised made no sense.  These are old bugs in complex_pow()
and friends:

1. Raising 0 to a negative power isn't a range error, it's a domain
   error, so changed c_pow() to set errno to EDOM in that case instead
   of ERANGE.

2. Changed complex_pow() to:

A. Used the Py_ADJUST_ERANGE2 macro to try to clear errno of a spurious
   ERANGE error due to underflow in the libm pow() called by c_pow().

B. Produced different exceptions depending on the errno value:
   i) For errno==EDOM, raise ZeroDivisionError instead of ValueError.
      This is for consistency with the non-complex cases 0.0**-2 and
      0**-2 and 0L**-2.
   ii) For errno==ERANGE, raise OverflowError.

Bugfix candidate.
2002-03-25 13:21:41 +00:00
Michael W. Hudson
c2a5e3c0f9 Martin's fix for
[ 529104 ] broken error handling in unicode-escape

I presume this will need to be fixed on the trunk, too.

Later.
2002-03-18 12:47:52 +00:00
Michael W. Hudson
36de099f04 Fix
[ 531306 ] ucs4 build horked.

Classic C mistake, I think.

Also squashed a couple of warnings in the ucs4 build.
2002-03-18 12:43:33 +00:00
Guido van Rossum
09f2187704 Fix for SF bug 528132 (Armin Rigo): classmethod().__get__() segfault
The proper fix is not quite what was submitted; it's really better to
take the class of the object passed rather than calling PyMethod_New
with NULL pointer args, because that can then cause other core dumps
later.

I also added a testcase for the fix to classmethods() in test_descr.py.

I'll apply this to 2.3 too.
2002-03-18 03:05:36 +00:00
Tim Peters
4d761f2443 SF patch 530070: pydoc regression, from Martin and Guido.
Change the way __doc__ is handled, to avoid blowing up on non-string
__doc__ values.
2002-03-17 18:57:07 +00:00
Michael W. Hudson
98305a0d34 Take Tim's work on file.truncate out of 2.2.1 again. 2002-03-17 15:55:50 +00:00
Michael W. Hudson
fe69139f7e Backport Tim's work on getting file.truncate working better on Win32.
"cvs diff | patch" managed to stick the NEWS item in the 2.2 final
section!  I wonder which silly man wrote patch <wink>.
2002-03-16 18:19:33 +00:00
Michael W. Hudson
18d81afd23 backport gvanrossum's checkin of
revision 2.129 of typeobject.c

"Fix" for SF bug #520644: __slots__ are not pickled.

As promised in my response to the bug report, I'm not really fixing
it; in fact, one could argule over what the proper fix should do.
Instead, I'm adding a little magic that raises TypeError if you try to
pickle an instance of a class that has __slots__ but doesn't define or
override __getstate__.  This is done by adding a bozo __getstate__
that always raises TypeError.
2002-03-16 17:56:51 +00:00
Michael W. Hudson
78f70880e2 backport gvanrossum's checkin of
revision 2.41 of moduleobject.c

Fix for SF bug #529050 - ModuleType.__new__ crash.

There were several places that assumed the md_dict field was always
set, but it needn't be.  Fixed these to be more careful.

I changed PyModule_GetDict() to initialize md_dict to a new dictionary
if it's NULL.

Bugfix candidate.
2002-03-15 10:35:36 +00:00
Tim Peters
f0cd73e215 Move to zlib 1.1.4 on Windows (the new version that squashes the "double
free" glitch).

unicodeobject.c:  squash compiler warnings.

Noting that test_pyclbr currently fails in 2.2.1:

    test_others (__main__.PyclbrTest) ... ??? HTTP11
    FAIL
2002-03-13 23:56:48 +00:00
Michael W. Hudson
095fbeb55b backport gvanrossum's checkin of
revision 2.128 of typeobject.c

Bugfix candidate.
Adapter from SF patch 528038; fixes SF bug 527816.

The wrapper for __nonzero__ should be wrap_inquiry rather than
wrap_unaryfunc, since the slot returns an int, not a PyObject *.
2002-03-11 10:19:48 +00:00
Michael W. Hudson
f97cf81f2f backport tim_one's checkin of
revision 2.111 of floatobject.c

SF bug 525705:  [2.2] underflow raise OverflowException.
Another year in the quest to out-guess random C behavior.

Added macros Py_ADJUST_ERANGE1(X) and Py_ADJUST_ERANGE2(X, Y).  The latter
is useful for functions with complex results.  Two corrections to errno-
after-libm-call are attempted:

1. If the platform set errno to ERANGE due to underflow, clear errno.
   Some unknown subset of libm versions and link options do this.  It's
   allowed by C89, but I never figured anyone would do it.

2. If the platform did not set errno but overflow occurred, force
   errno to ERANGE.  C89 required setting errno to ERANGE, but C99
   doesn't.  Some unknown subset of libm versions and link options do
   it the C99 way now.

Bugfix candidate, but hold off until some Linux people actually try it,
with and without -lieee.  I'll send a help plea to Python-Dev.
2002-03-11 10:17:17 +00:00
Michael W. Hudson
43efb9a1af Probably should have merged the two checkins to this file (oh well).
backport jhylton's checkin of
    revision 2.98 of abstract.c

Fix leak of NotImplemented in previous checkin to PyNumber_Add().

If result == Py_NotImplemented, always DECREF it before assigning a
new value to result.
2002-03-11 10:12:58 +00:00
Michael W. Hudson
244ca00bf0 backport jhylton's checkin of
revision 2.97 of abstract.c

Fix for SF bug 516727: MyInt(2) + "3" -> NotImplemented

PyNumber_Add() tries the nb_add slot first, then falls back to
sq_concat.  However, it didn't check the return value of sq_concat.
If sq_concat returns NotImplemented, raise the standard TypeError.
2002-03-11 10:11:46 +00:00
Michael W. Hudson
a374b6f469 backport my checkin of
revision 1.6 of structseq.c

Guido pointed out that I was missing a couple decrefs.
2002-03-07 15:16:07 +00:00
Michael W. Hudson
aa3fd6f3df After some thinking, I decided to move all of this across onto
the branch.  I don't think it can break code, so the only risk
is introducing new bugs.  In that vein, can I ask -checkins readers
who have time to carefully look this over, check my refcounts &c?
TIA.

backport my checkin of
    revision 1.5 of structseq.c

Apply (my) patch:

[ 526072 ] pickling os.stat results round II

structseq's constructors can now take "invisible" fields in a dict.
Gave the constructors better error messages.
their __reduce__ method puts these fields in a dict.

(this is all in aid of getting os.stat_result's to pickle portably)

Also fixes

[ 526039 ] devious code can crash structseqs

Thought needed about how much of this counts as a bugfix.  Certainly
#526039 needs to be fixed.
2002-03-07 10:16:43 +00:00
Michael W. Hudson
325573ce28 backport tim_one's checkin of
revision 1.114 of longobject.c

_PyLong_Copy():  was creating a copy of the absolute value, but should
copy the sign too.  Added a test to test_descr to ensure that it does.

Bugfix candidate.
2002-03-05 15:42:48 +00:00
Michael W. Hudson
c4562a89ea Backport the bits of Guido's fix for
SF patch 514641 (Naofumi Honda) - Negative ob_size of LongObjects

that Tim didn't later back out.
2002-03-05 15:41:40 +00:00
Michael W. Hudson
fc7af7705c backport tim_one's checkin of
revision 2.164 of object.c

Whether platform malloc(0) returns NULL has nothing to do with whether
platform realloc(p, 0) returns NULL, so MALLOC_ZERO_RETURNS_NULL can
be correctly undefined yet realloc(p, 0) can return NULL anyway.

Prevent realloc(p, 0) doing free(p) and returning NULL via a different
hack.  Would probably be better to get rid of MALLOC_ZERO_RETURNS_NULL
entirely.

Bugfix candidate.
2002-03-05 14:23:56 +00:00
Michael W. Hudson
5660b8e396 backport my checkin of
revision 1.4 of structseq.c

A fix & test for

[ 496873 ] structseqs unpicklable

by adding a __reduce__ method to structseqs.

Will also commit this to the 2.2.1 branch momentarily.
2002-03-05 14:00:52 +00:00
Marc-André Lemburg
679e4314fd Whitespace normalization and minor cosmetics. 2002-02-25 14:51:00 +00:00
Marc-André Lemburg
d53e226f81 Fix UTF-8 encoder pointer arithmetic and restore 2.2 behaviour. 2002-02-25 14:30:49 +00:00
Michael W. Hudson
6c7078b582 Fix the problem reported in
[ #495401 ] Build troubles: --with-pymalloc

in a slightly different manner to the trunk, as discussed on python-dev.
2002-02-22 13:44:43 +00:00
Michael W. Hudson
62f0734077 backport loewis' checkin of
revision 2.127 of typeobject.c

Allow __doc__ to be of arbitrary type. Patch by James Henstridge,
fixes #504343. 2.2.1 candidate.
2002-02-22 13:31:18 +00:00
Michael W. Hudson
03474c5c5d backport gvanrossum's checkin of
revision 2.54 of complexobject.c

Declare real and imag as read-only attributes.

This fixes SF bug #514858 (Gregory Smith): complex not entirely
immutable

2.2.1 Bugfix candidate!
2002-02-22 13:23:33 +00:00