Commit Graph

2653 Commits

Author SHA1 Message Date
Neal Norwitz ca63121553 Backport 52506:
Don't inline Py_ADDRESS_IN_RANGE with gcc 4+ either.
2006-10-28 21:39:31 +00:00
Neal Norwitz e0cf624747 Backport 52505:
Prevent crash if alloc of garbage fails.  Found by Typo.pl.
2006-10-28 21:39:10 +00:00
Neal Norwitz 7e3ec048f9 Backport 52502:
Fix warnings with HP's C compiler.  It doesn't recognize that infinite
loops are, um, infinite.  These conditions should not be able to happen.
2006-10-28 21:37:16 +00:00
Thomas Heller a0a50feea8 WindowsError.str should display the windows error code,
not the posix error code; with test.
Fixes #1576174.

Backported from trunk, revision 52485.
2006-10-27 18:47:29 +00:00
Georg Brandl dd4c398c27 Bug #1545497: when given an explicit base, int() did ignore NULs
embedded in the string to convert.
 (backport from rev. 52305)
2006-10-12 11:28:04 +00:00
Armin Rigo 4b63c21d6f Forward-port of r52136: a review of overflow-detecting code.
* unified the way intobject, longobject and mystrtoul handle
  values around -sys.maxint-1.

* in general, trying to entierely avoid overflows in any computation
  involving signed ints or longs is extremely involved.  Fixed a few
  simple cases where a compiler might be too clever (but that's all
  guesswork).

* more overflow checks against bad data in marshal.c.

* 2.5 specific: fixed a number of places that were still confusing int
  and Py_ssize_t.  Some of them could potentially have caused
  "real-world" breakage.

* list.pop(x): fixing overflow issues on x was messy.  I just reverted
  to PyArg_ParseTuple("n"), which does the right thing.  (An obscure
  test was trying to give a Decimal to list.pop()... doesn't make
  sense any more IMHO)

* trying to write a few tests...
2006-10-04 11:44:06 +00:00
Martin v. Löwis 10525ad313 Fix integer negation and absolute value to not rely
on undefined behaviour of the C compiler anymore.
2006-10-04 05:47:47 +00:00
Georg Brandl 506cc189a9 Bug #1566800: make sure that EnvironmentError can be called with any
number of arguments, as was the case in Python 2.4.
 (backport from rev. 52061)
2006-09-30 09:03:45 +00:00
Georg Brandl af4337a017 Patch #1567691: super() and new.instancemethod() now don't accept
keyword arguments any more (previously they accepted them, but didn't
use them).
 (backport from rev. 52058)
2006-09-30 08:43:50 +00:00
Brett Cannon c70e003f75 Backport of fix to allow exception instances to be sliced once again. 2006-09-21 18:12:15 +00:00
Brett Cannon 19d76c5aa8 Remove __unicode__ method so that ``unicode(BaseException)`` succeeds.
Fixes bug #1551432.
2006-09-09 07:18:44 +00:00
Georg Brandl 8de403a56a Backport rev. 51798 from trunk:
fix setobject.c refcounts and error checks.
2006-09-08 06:02:26 +00:00
Georg Brandl ecab623e13 Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack.
Also make sure that every exception class has __module__ set to
'exceptions'.
 (backport)
2006-09-06 06:47:02 +00:00
Neal Norwitz fe50f8e961 Backport 51669: Make sure memory is properly cleaned up in file_init (even though this should not be able to happen since we already parsed the args) 2006-09-05 04:32:06 +00:00
Neal Norwitz 29a5fdb7ca Fix str.rpartition(sep) when sep is not found in str.
Partially from SF patch #1551339, but also taken from head.
2006-09-05 02:21:38 +00:00
Neal Norwitz d3da7d394a Fix SF bug #1546288, crash in dict_equal 2006-09-05 01:54:06 +00:00
Tim Peters cbdd350dd7 i_divmod(): As discussed on Python-Dev, changed the overflow
checking to live happily with recent gcc optimizations that
assume signed integer arithmetic never overflows.
2006-09-05 01:47:53 +00:00
Neal Norwitz 19c35bba5d - Patch #1541585: fix buffer overrun when performing repr() on
a unicode string in a build with wide unicode (UCS-4) support.

I will forward port to 2.6.  Can someone backport to 2.4?
2006-08-21 22:13:11 +00:00
Neal Norwitz 47f0ffa7ee Fix a couple of ssize-t issues reported by Alexander Belopolsky on python-dev 2006-08-21 18:44:09 +00:00
Neal Norwitz 3ba24783ba Move initialization of interned strings to before allocating the
object so we don't leak op.  (Fixes an earlier patch to this code)

Klockwork #350
2006-08-19 04:19:14 +00:00
Neal Norwitz 271a8689e9 Subclasses of int/long are allowed to define an __index__. 2006-08-15 06:29:03 +00:00
Georg Brandl 26a07b5198 Fix refleak introduced in rev. 51248. 2006-08-14 20:25:39 +00:00
Marc-André Lemburg 3a457790c7 Correct an accidentally removed previous patch. 2006-08-14 12:57:27 +00:00
Marc-André Lemburg 040f76b79c Slightly revised version of patch #1538956:
Replace UnicodeDecodeErrors raised during == and !=
compares of Unicode and other objects with a new
UnicodeWarning.

All other comparisons continue to raise exceptions.
Exceptions other than UnicodeDecodeErrors are also left
untouched.
2006-08-14 10:55:19 +00:00
Neal Norwitz af33f2d571 Can't return NULL from a void function. If there is a memory error,
about the best we can do is call PyErr_WriteUnraisable and go on.
We won't be able to do the call below either, so verify delstr is valid.
2006-08-14 00:59:03 +00:00
Neal Norwitz 56423e5762 Fix segfault when doing string formatting on subclasses of long if
__oct__, __hex__ don't return a string.

Klocwork 308
2006-08-13 18:11:08 +00:00
Neal Norwitz b09f4f578f Handle a whole lot of failures from PyString_FromInternedString().
Should fix most of Klocwork 234-272.
2006-08-13 18:10:28 +00:00
Neal Norwitz 1872b1c01f Fix a couple of bugs exposed by the new __index__ code. The 64-bit buildbots
were failing due to inappropriate clipping of numbers larger than 2**31
with new-style classes. (typeobject.c)  In reviewing the code for classic
classes, there were 2 problems.  Any negative value return could be returned.
Always return -1 if there was an error.  Also make the checks similar
with the new-style classes.  I believe this is correct for 32 and 64 bit
boxes, including Windows64.

Add a test of classic classes too.
2006-08-12 18:44:06 +00:00
Neal Norwitz 8a87f5d37e Patch #1538606, Patch to fix __index__() clipping.
I modified this patch some by fixing style, some error checking, and adding
XXX comments.  This patch requires review and some changes are to be expected.
I'm checking in now to get the greatest possible review and establish a
baseline for moving forward.  I don't want this to hold up release if possible.
2006-08-12 17:03:09 +00:00
Neal Norwitz b88cfad318 Check return of PyMem_MALLOC (garbage) is non-NULL.
Check seq in both portions of if/else.

Klocwork #289-290.
2006-08-12 03:16:54 +00:00
Neal Norwitz 421c1319ad Whoops, how did that get in there. :-) Revert all the parts of 51227 that were not supposed to go it. Only Modules/_ctypes/cfields.c was supposed to be changed 2006-08-12 02:12:30 +00:00
Neal Norwitz 6b4953fd3d Check returned pointer is valid.
Klocwork #233
2006-08-12 02:06:34 +00:00
Neal Norwitz 6f5ff3f3eb Klocwork made another run and found a bunch more problems.
This is the first batch of fixes that should be easy to verify based on context.

This fixes problem numbers: 220 (ast), 323-324 (symtable),
321-322 (structseq), 215 (array), 210 (hotshot), 182 (codecs), 209 (etree).
2006-08-12 01:43:40 +00:00
Armin Rigo 51fc8c456e Fix and test for an infinite C recursion. 2006-08-09 14:55:26 +00:00
Martin v. Löwis ab2f8f7bd5 __hash__ may now return long int; the final hash
value is obtained by invoking hash on the long int.
Fixes #1536021.
2006-08-09 07:57:39 +00:00
Thomas Heller ab1049c046 memcmp() can return values other than -1, 0, and +1 but tp_compare
must not.
2006-08-08 17:37:00 +00:00
Georg Brandl b0061c8e93 Remove "non-mapping" and "non-sequence" from TypeErrors raised by
PyMapping_Size and PySequence_Size.

Because len() tries first sequence, then mapping size, it will always
raise a "non-mapping object has no len" error which is confusing.
2006-08-08 11:56:21 +00:00
Andrew M. Kuchling 0067b5fa2b Typo fixes 2006-08-04 20:37:43 +00:00
Georg Brandl e9462c72bd Change fix for segfaulting property(), add a NEWS entry and a test. 2006-08-04 18:03:37 +00:00
Georg Brandl 45381938e9 Fix bug caused by first decrefing, then increfing. 2006-08-04 06:03:53 +00:00
Fred Drake 7a36f5f344 SF patch #1534048 (bug #1531003): fix typo in error message 2006-08-04 05:17:21 +00:00
Neal Norwitz c5e060dee6 _PyWeakref_GetWeakrefCount() now returns a Py_ssize_t instead of long. 2006-08-02 06:14:22 +00:00
Andrew M. Kuchling 5a51bf50b8 typo fix 2006-08-01 16:24:30 +00:00
Neal Norwitz a7edb11122 Whitespace normalization 2006-07-30 06:59:13 +00:00
Neal Norwitz f71ec5a0ac Bug #1515471: string.replace() accepts character buffers again.
Pass the char* and size around rather than PyObject's.
2006-07-30 06:57:04 +00:00
Andrew M. Kuchling 52740be425 [Bug #1414697] Change docstring of set/frozenset types to specify that the contents are unique. Raymond, please feel free to edit or revert. 2006-07-29 15:10:32 +00:00
Neal Norwitz 101bac205d Closure can't be NULL at this point since we know it's a tuple.
Reported by Klocwork # 74.
2006-07-27 03:55:39 +00:00
Neal Norwitz c09efa8444 Move the initialization of size_a down below the check for a being NULL.
Reported by Klocwork #106
2006-07-23 07:53:14 +00:00
Neal Norwitz e1fdb32ff2 Handle allocation failures gracefully. Found with failmalloc.
Many (all?) of these could be backported.
2006-07-21 05:32:28 +00:00
Neal Norwitz 1adbb50701 Move the initialization of some pointers earlier. The problem is
that if we call Py_DECREF(frame) like we do if allocating locals fails,
frame_dealloc() will try to use these bogus values and crash.
2006-07-21 05:31:02 +00:00