Commit Graph

2721 Commits

Author SHA1 Message Date
Amaury Forgeot d'Arc afa0d58a2d Issue #3751: str.rpartition would perform a left-partition when called with
a unicode argument.

Backport of r66119
2008-09-01 20:05:08 +00:00
Georg Brandl 45c33ce62d - Issue #3537: Fix an assertion failure when an empty but presized dict
object was stored in the freelist. (backport from r65637.)
2008-08-11 09:13:26 +00:00
Neal Norwitz 4f3be8a0a9 Security patches from Apple: prevent int overflow when allocating memory 2008-07-31 17:08:14 +00:00
Neal Norwitz 83ac0144fa Backport code from r65182:
Issue #2620: Overflow checking when allocating or reallocating memory
was not always being done properly in some python types and extension
modules.  PyMem_MALLOC, PyMem_REALLOC, PyMem_NEW and PyMem_RESIZE have
all been updated to perform better checks and places in the code that
would previously leak memory on the error path when such an allocation
failed have been fixed.
2008-07-28 05:06:20 +00:00
Antoine Pitrou c8e4bed1c5 #2242: utf7 decoding crashes on bogus input on some Windows/MSVC versions 2008-07-25 19:00:48 +00:00
Amaury Forgeot d'Arc 3255e134fe Issue 3110: Crash with weakref subclass,
seen after a "import multiprocessing.reduction"

An instance of a weakref subclass can have attributes.
If such a weakref holds the only strong reference to the object,
deleting the weakref will delete the object. In this case,
the callback must not be called, because the ref object is being deleted!

Backport of r34309
2008-06-16 19:22:42 +00:00
Gregory P. Smith 9e6649f8ee Backport r61468 from trunk: Improves the text of the IOError raised
when open() returns EINVAL.  See issue2158.
2008-05-03 07:12:23 +00:00
Amaury Forgeot d'Arc 0f1653e957 Correct previous checkin, probably a svn merge issue.
Now the code is similar to the one in trunk/.

The behavior was funny:
   >>> print (), repr(())
   (), ()
   >>> print (), repr(())
   (), (...)
2008-04-11 00:33:07 +00:00
Guido van Rossum aa975432d4 - Issue #1686386: Tuple's tp_repr did not take into account the possibility of
having a self-referential tuple, which is possible from C code.  Nor did
  object's tp_str consider that a type's tp_str could do something that could
  lead to an inifinite recursion.  Py_ReprEnter() and Py_EnterRecursiveCall(),
  respectively, fixed the issues.  (Backport of r58288 from trunk to 2.5.)
2008-04-10 22:43:58 +00:00
Gregory P. Smith a6add69a63 backport r62271 from trunk.
remove the now obsoleted assertion.
2008-04-10 19:54:13 +00:00
Gregory P. Smith 14acde30f6 Backport r62261 from trunk:
Prevent PyString_FromStringAndSize() from passing negative sizes on to lower
level memory allocation functions.  Raise a SystemError and return NULL
instead.
2008-04-09 23:41:13 +00:00
Amaury Forgeot d'Arc a79e05097b #1477: ur'\U0010FFFF' used to raise in narrow unicode builds.
Corrected the raw-unicode-escape codec to use UTF-16 surrogates in
this case, like the unicode-escape codec does.

Backport of r61793 and r61853
2008-03-24 21:16:28 +00:00
Neal Norwitz b3635f99a2 Backport r61458:
Issue 2321: reduce memory usage (increase the memory that is returned
to the system) by using pymalloc for the data of unicode objects.
2008-03-18 04:17:36 +00:00
Guido van Rossum 44a93e54f4 Fix the overflows in expandtabs(). "This time for sure!"
(Exploit at request.)
2008-03-11 21:14:54 +00:00
Martin v. Löwis 73c01d4101 Added checks for integer overflows, contributed by Google. Some are
only available if asserts are left in the code, in cases where they
can't be triggered from Python code.
2008-02-14 11:26:18 +00:00
Thomas Wouters 6bf585e753 Fix typo in constant name. 2008-01-25 21:08:41 +00:00
Thomas Wouters d92272e4a9 Use the right (portable) definition of the max of a Py_ssize_t. 2008-01-25 19:51:24 +00:00
Guido van Rossum ee6bab06d3 Rewrite the list_inline_repeat overflow check slightly differently. 2008-01-25 19:42:36 +00:00
Guido van Rossum 1859f5b4d2 Backport r60246.
Fix issue #1303614, test67.py.
2008-01-24 17:59:56 +00:00
Guido van Rossum 03706d2db0 Backport r55080:
Fix for #1303614 and #1174712:
- __dict__ descriptor abuse for subclasses of built-in types
- subclassing from both ModuleType and another built-in types
2008-01-18 21:31:32 +00:00
Guido van Rossum d187381b81 Fix an edge case whereby the __del__() method of a classic class could
create a new weakref to the object.
2008-01-18 20:53:37 +00:00
Christian Heimes 03acd85dbf merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError 2007-12-05 12:51:23 +00:00
Georg Brandl a5463ab7de Spaces vs. Tabs.
(backport from rev. 59224)
2007-11-29 18:33:04 +00:00
Guido van Rossum dbe97b38be Fix bug #1517, a possible segfault in lookup(). 2007-11-29 18:23:48 +00:00
Amaury Forgeot d'Arc 30f61cbb13 Issue #1445: Fix a SystemError when accessing the ``cell_contents``
attribute of an empty cell object.  Now a ValueError is raised.

Backport of r59170.
2007-11-24 13:53:29 +00:00
Guido van Rossum 809123c61f Issue 1704621. Fix segfaults in list_repeat() and list_inplace_repeat().
The C changes aren't quite the same as the patch given there; the test is.
2007-11-12 20:04:41 +00:00
Guido van Rossum e6a6f39cc7 Backport r58892.
Add missing "return NULL" in overflow check in PyString_Repr().
2007-11-07 01:19:49 +00:00
Georg Brandl 1dcb9c93fd Backport r58709 from trunk:
Backport fixes for the code that decodes octal escapes (and for PyString
also hex escapes) -- this was reaching beyond the end of the input string
buffer, even though it is not supposed to be \0-terminated.
This has no visible effect but is clearly the correct thing to do.
(In 3.0 it had a visible effect after removing ob_sstate from PyString.)
Also fixes #1098.
2007-11-02 22:46:38 +00:00
Brett Cannon 13bfa3a97b Cause passing a string to generator.throw() to raise a deprecation warning. 2007-09-11 21:12:14 +00:00
Georg Brandl b4d100cf2d Bug #1763149: use proper slice syntax in docstring.
(backport)
2007-07-29 17:37:22 +00:00
Georg Brandl c5db923994 Patch #1673759: add a missing overflow check when formatting floats
with %G.
 (backport from rev. 56298)
2007-07-12 08:38:04 +00:00
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