Commit Graph

2690 Commits

Author SHA1 Message Date
Neal Norwitz 8355dd5806 Backport 55874:
Fix a bug when there was a newline in the string expandtabs was called on.
This also catches another condition that can overflow.
2007-06-11 04:32:41 +00:00
Neal Norwitz 66e64e2b6a Prevent expandtabs() on string and unicode objects from causing a segfault when
a large width is passed on 32-bit platforms.  Found by Google.

It would be good for people to review this especially carefully and verify
I don't have an off by one error and there is no other way to cause overflow.
2007-06-09 04:06:30 +00:00
Martin v. Löwis 897704d1dd Bug #1733488: Fix compilation of bufferobject.c on AIX. 2007-06-08 17:29:40 +00:00
Neal Norwitz 5ece2fb0d1 Add what looks like a necessary call to PyErr_NoMemory() when PyMem_MALLOC()
fails.
2007-05-16 04:35:11 +00:00
Kristján Valur Jónsson a1392d5ace Merge change 54982 from the trunk. This fixes the test_subprocess test in the testsuite for VisualStudio2005 builds, by "sanitizing" the "mode" that is used in the posixmodule's fdopen(). In particular the non-standard "U" mode character is removed. 2007-05-07 19:25:38 +00:00
Kristján Valur Jónsson dffe9a214b the nb_long slot on classobject instances now defaults to call the nb_int slot member if there is no __long__ attribute found. This is in accordance with a suggestion from Armin Rigo, and allows the test_getargs2.py test in the testsuite for x64 2007-05-07 18:36:39 +00:00
Kristján Valur Jónsson f4601d874f Fix two problems that emerged when the testsuite was run with an x64 build: PyLong_FromSSize_t incorrectly assumed an unsigned object, and itertools.count() had the wrong upper limit for the iterator. 2007-05-07 18:30:48 +00:00
Georg Brandl 1dfa8ac6f1 Backport r54757 - missing NULL checks. 2007-04-21 07:22:57 +00:00
Raymond Hettinger 87b5d9196e Revert 53667 2007-04-18 02:02:15 +00:00
Neal Norwitz e6e383f498 Revert SF #1615701 (rev 53655): dict.update() does *not* call __getitem__() or
keys() if subclassed.  This is to remain consistent with 2.5.

See discussion here:
  http://mail.python.org/pipermail/python-dev/2007-April/072565.html
2007-04-16 06:59:13 +00:00
Neal Norwitz 03c566a268 Revert 54813 for 2.5.1 release. Can be applied after 2.5 branch is unfrozen. 2007-04-16 06:19:52 +00:00
Kristján Valur Jónsson 9d9fbb4359 Fix a bug when using the __lltrace__ opcode tracer, and a problem sith signed chars in frameobject.c which can occur with opcodes > 127 2007-04-13 22:09:59 +00:00
Raymond Hettinger 7ed0a65831 Test and fix fromkeys optional argument. 2007-03-21 20:36:45 +00:00
Raymond Hettinger f94e89c578 Extend work on rev 52962 and 53830 eliminating redundant PyObject_Hash() calls and fixing set/dict interoperability. 2007-03-20 21:45:04 +00:00
Žiga Seilnacht c1b4e8e6e2 Patch #1462488: prevent a segfault in object_reduce_ex() by splitting
the implementation for __reduce__ and __reduce_ex__ into two separate
functions. Fixes bug #931877.
 (backport from rev. 54397)
2007-03-15 11:47:59 +00:00
Žiga Seilnacht 94c887258c Patch #1680015: Don't modify __slots__ tuple if it contains an unicode
name. Remove a reference leak that happened if the name could not be
converted to string.
 (backport from rev. 54378)
2007-03-14 12:34:30 +00:00
Žiga Seilnacht ad3d2c2fe4 Patch #1675981: remove unreachable code from type.__new__() method.
__dict__ and __weakref__ are removed from the slots tuple earlier
in the code, in the loop that mangles slot names.
 (backport from rev. 54270)
2007-03-11 16:01:51 +00:00
Neal Norwitz e7881559f2 Fix SF #1676971, Complex OverflowError has a typo 2007-03-09 06:01:28 +00:00
Georg Brandl ffb0a804c6 Patch #1638879: don't accept strings with embedded NUL bytes in long().
(backport from rev. 54173)
2007-03-06 18:44:35 +00:00
Georg Brandl 5f795865da Backport from Py3k branch: fix refleak in PyString_Format.
(backport from rev. 53935)
2007-02-26 13:51:34 +00:00
Raymond Hettinger d621a6e8dc Fixup set/dict interoperability. 2007-02-19 20:45:46 +00:00
Raymond Hettinger 1bff796983 Extend work on revision 52962: Eliminate redundant calls to PyObject_Hash(). 2007-02-19 03:04:45 +00:00
Martin v. Löwis b4af42a635 Bug #1653736: Properly discard third argument to slot_nb_inplace_power. 2007-02-09 12:19:46 +00:00
Raymond Hettinger fdf7bf8305 Bypass set specific optimizations for set and frozenset subclasses. 2007-02-08 00:49:51 +00:00
Raymond Hettinger 9f0e1ea964 Do not let overflows in enumerate() and count() pass silently. 2007-02-07 23:57:05 +00:00
Raymond Hettinger bbe92887ce Silence compiler warning 2007-02-07 23:48:15 +00:00
Raymond Hettinger 127ef44c7b Bug #1575169: operator.isSequenceType() now returns False for subclasses of dict. 2007-02-07 22:12:01 +00:00
Raymond Hettinger 20dcf1cb9d SF #1615701: make d.update(m) honor __getitem__() and keys() in dict subclasses 2007-02-07 20:01:28 +00:00
Raymond Hettinger 21191f4f0c Bug #1648179: set.update() not recognizing __iter__ overrides in dict subclasses. 2007-02-01 21:01:21 +00:00
Brett Cannon 75ba075110 If you created a weakref in an object's __del__ method to itself it would
segfault the interpreter during weakref clean up.  Now any new weakrefs created
after __del__ is run are removed silently.

Fixes bug #1377858 and the weakref_in_del crasher for new-style classes.
Classic classes are still affected.
2007-01-23 22:41:20 +00:00
Thomas Wouters e471317a08 Backport trunk revision 53527:
SF patch #1630975: Fix crash when replacing sys.stdout in sitecustomize

When running the interpreter in an environment that would cause it to set
stdout/stderr/stdin's encoding, having a sitecustomize that would replace
them with something other than PyFile objects would crash the interpreter.
Fix it by simply ignoring the encoding-setting for non-files.

This could do with a test, but I can think of no maintainable and portable
way to test this bug, short of adding a sitecustomize.py to the buildsystem
and have it always run with it (hmmm....)
2007-01-23 13:54:30 +00:00
Raymond Hettinger 535989ecb6 SF #1486663 -- Allow keyword args in subclasses of set() and frozenset(). 2007-01-11 18:21:04 +00:00
Raymond Hettinger 9cdf70399f For sets with cyclical reprs, emit '...' instead of recursing. 2006-12-29 18:49:13 +00:00
Raymond Hettinger 775ebe29a5 Backport fixes to set objects:
rev 52964 sf 1576657 KeyError unpacks tuple arguments
rev 52963 sf 1456209 obscure resizing vulnerability
rev 52962 redundant calls to PyObject_Hash()
2006-12-08 18:12:24 +00:00
Martin v. Löwis a1e3422205 Correctly forward exception in instance_contains().
Fixes #1591996. Patch contributed by Neal Norwitz.
2006-11-08 06:46:49 +00:00
Neal Norwitz ae6b84184b Fix refleak 2006-10-29 23:42:59 +00:00
Georg Brandl 5e9f94ac7a Bug #1576657: when setting a KeyError for a tuple key, make sure that
the tuple isn't used as the "exception arguments tuple".
 (backport from rev. 52535)
2006-10-29 18:31:45 +00:00
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