Commit Graph

3753 Commits

Author SHA1 Message Date
bennorth c20c97f612 bpo-18533: Avoid RuntimeError from repr() of recursive dictview (#4823) (#5357)
(cherry picked from commit d7773d92bd)
2018-02-27 00:35:03 +02:00
Serhiy Storchaka b7a2c17be8
[2.7] bpo-32137: The repr of deeply nested dict now raises a RuntimeError (GH-4570) (#5493)
instead of crashing due to a stack overflow.

This perhaps will fix similar problems in other extension types.
(cherry picked from commit 1fb72d2ad2)
2018-02-02 16:29:02 +02:00
Benjamin Peterson eb08a9290f
coalesce GILless sections in new_buffersize (#5059)
830daae1c8 added some new GIL-releasing to new_buffersize. This is fine, but it's better to avoid reacquiring the GIL for as long as possible. Also, it should use FILE_(BEGIN|END)_ALLOW_THREADS to avoid having the file closed from under it.
2018-01-02 15:52:42 -08:00
Benjamin Peterson dbf52e02f1
bpo-31530: fix crash when multiple threads iterate over a file, round 2 (#5060)
Multiple threads iterating over a file can corrupt the file's internal readahead
buffer resulting in crashes. To fix this, cache buffer state thread-locally for
the duration of a file_iternext call and only update the file's internal state
after reading completes.

No attempt is made to define or provide "reasonable" semantics for iterating
over a file on multiple threads. (Non-crashing) races are still
present. Duplicated, corrupt, and missing data will happen.

This was originally fixed by 6401e56717, which
raised an exception from seek() and next() when concurrent operations were
detected. Alas, this simpler solution breaks legitimate use cases such as
capturing the standard streams when multiple threads are logging.
2018-01-02 09:25:41 -08:00
Nir Soffer 830daae1c8 [2.7] bpo-32186: Release the GIL during fstat and lseek calls (#4651)
In fileio, there were 3 fstat() calls and one lseek() call that did not
release the GIL during the call. This can cause all threads to hang for
unlimited time when using io.FileIO with inaccessible NFS server.

Same issue seen in fileio exists also in fileobject, fixed in the same
way.
2017-12-07 21:25:39 +01:00
Victor Stinner ed4743a2f2
bpo-31626: Fix _PyObject_DebugReallocApi() (#4310)
_PyObject_DebugReallocApi() now calls Py_FatalError() if realloc()
fails to shrink a memory block.

Call Py_FatalError() because _PyObject_DebugReallocApi() erased freed
bytes *before* realloc(), expecting that realloc() *cannot* fail to
shrink a memory block.
2017-11-24 02:13:26 +01:00
Serhiy Storchaka 6401e56717
[2.7] bpo-31530: Stop crashes when iterating over a file on multiple threads. (#3672) 2017-11-10 12:58:55 +02:00
Victor Stinner 52ba7b447f
bpo-20064: Document PyObject_Malloc() (#4204)
Document the following functions:

* PyObject_Malloc()
* PyObject_Realloc()
* PyObject_Free()

Document also the pymalloc allocator.
2017-10-31 10:08:28 -07:00
Serhiy Storchaka 107f3cc791
[2.7] bpo-20047: Make bytearray methods partition() and rpartition() rejecting (GH-4158) (#4163)
separators that are not bytes-like objects..
(cherry picked from commit a2314283ff)
2017-10-29 12:25:38 +02:00
Serhiy Storchaka 19eb87d857 [2.7] bpo-31579: Fixed a possible leak in enumerate() with large indices. (GH-3753). (#3761)
(cherry picked from commit 0e950dd22b)
2017-09-26 09:11:27 +03:00
Benjamin Peterson a72d15c97f consistently use Py_TYPE, Py_REFCNT, and correct initializer macros (#3563)
This no-op change makes 2.7 more consistent with 3.x to ease comparison and backports.
2017-09-13 21:20:29 -07:00
INADA Naoki 4cde4bdcc8 bpo-31095: Fix potential crash during GC (GH-3197)
(cherry picked from commit a6296d34a4)
2017-09-04 12:31:41 +09:00
Serhiy Storchaka 3dd1ccbb09 bpo-29902: Emit a Py3k deprecation warning when pickling or copying (#2823)
some builtin and extension objects that don't support pickling
explicitly and are pickled incorrectly by default (like memoryview or
staticmethod).
2017-08-02 11:33:33 +03:00
Jay Bosamiya c3c9db8927 [2.7] bpo-30657: Check & prevent integer overflow in PyString_DecodeEscape (#2174) 2017-06-18 19:41:03 +03:00
Serhiy Storchaka e6a0b59829 [2.7] bpo-27945: Fixed various segfaults with dict. (GH-1657) (#1681)
Based on patches by Duane Griffin and Tim Mitchell.
(cherry picked from commit 753bca3934)
2017-05-20 20:05:27 +03:00
Serhiy Storchaka e9f9b04278 [2.7] bpo-25794: Fix `type.__setattr__()` for non-interned or unicode attribute names. (GH-1652) (#1675)
Based on patch by Eryk Sun.
(cherry picked from commit d896985bb2)
2017-05-20 10:04:53 +03:00
Xiang Zhang 05469fa1c0 bpo-30281: Fix the default value for stop in PySlice_Unpack() (#1531) (#1480) 2017-05-10 19:20:28 +08:00
Victor Stinner f6a3133972 bpo-30255: Clip step in _PySlice_Unpack() (#1429)
In PySlice_IndicesEx, clip the step to [-PY_SSIZE_T_MAX,
PY_SSIZE_T_MAX] rather than [PY_SSIZE_T_MIN, PY_SSIZE_T_MAX].

(cherry picked from commit e6fc7401a9)
2017-05-03 16:00:12 +02:00
Serhiy Storchaka 5e79321742 bpo-30074: Fix compile warnings of _PySlice_Unpack and convert missed (#1154)
PySlice_GetIndicesEx in _ctypes.c.
2017-04-15 20:11:12 +03:00
Serhiy Storchaka e41390aca5 bpo-27867: Expand the PySlice_GetIndicesEx macro. (#1023) (#1046)
(cherry picked from commit b879fe8)
2017-04-08 11:48:57 +03:00
Serhiy Storchaka 079f21f873 bpo-29935: Fixed error messages in the index() method of tuple and list (#887) (#907) (#910)
when pass indices of wrong type.
(cherry picked from commit d4edfc9abf)
(cherry picked from commit bf4bb2e430)
2017-03-30 20:32:18 +03:00
Mark Dickinson c0b336e0ad bpo-29602: fix signed zero handling in complex constructor (#204)
* bpo-29602: fix signed zero handling in complex constructor

* Add missing have_getformat definition; remove use of unittest subtests.
2017-02-20 21:14:52 +00:00
Xiang Zhang 7131a73f96 bpo-29347: Fix possibly dereferencing undefined pointers when creating weakref objects (#128) (#187) 2017-02-20 14:32:53 +08:00
Serhiy Storchaka 8e21cc3ce0 Issue #29028: Fixed possible use-after-free bugs in the subscription of the
buffer object with custom index object.
2017-02-01 22:47:44 +02:00
Serhiy Storchaka 3efe32ed48 Issue #27867: Replaced function PySlice_GetIndicesEx() with a macro. 2017-01-25 13:22:06 +02:00
Xiang Zhang 7bdb516059 Issue #29145: Fix overflow checks in string, bytearray and unicode.
Patch by jan matejek and Xiang Zhang.
2017-01-09 11:13:20 +08:00
Antoine Pitrou f939b3c0f7 Issue #28427: old keys should not remove new values from
WeakValueDictionary when collecting from another thread.
2016-12-27 15:08:27 +01:00
Serhiy Storchaka 994f04dbf5 Issue #28998: More APIs now support longs as well as ints. 2016-12-27 15:09:36 +02:00
INADA Naoki e126f98658 Issue #29019: Fix dict.fromkeys(x) overallocates when x is sparce dict.
Original patch by Rasmus Villemoes.
2016-12-20 16:07:18 +09:00
Benjamin Peterson 4403d501ac revert a37cc3d926ec (#5322) 2016-12-13 23:30:16 -08:00
Benjamin Peterson d1aad3fceb Backed out changeset ea904d4b3634 2016-12-13 23:27:56 -08:00
Benjamin Peterson f8f2138bd4 fix refleak in reduce_2 error case 2016-12-03 12:08:24 -08:00
Benjamin Peterson 445844993b fix refleak in the shift-by-zero case (#27870) 2016-12-03 11:01:50 -08:00
Benjamin Peterson cffc0f4178 declarations to the top of the block 2016-12-02 00:02:24 -08:00
Serhiy Storchaka daf82f7539 Issue #5322: Fixed setting __new__ to a PyCFunction inside Python code.
Original patch by Andreas Stührk.
2016-12-02 08:42:43 +02:00
Serhiy Storchaka c30f27d1f2 Issue #11145: Fixed miscellaneous issues with C-style formatting of types
with custom __oct__ and __hex__.
2016-12-01 10:27:11 +02:00
Serhiy Storchaka 13cc67946b Issue #24469: Fixed memory leak caused by int subclasses without overridden
tp_free (e.g. C-inherited Cython classes).
2016-11-29 20:49:14 +02:00
Yury Selivanov 48aa605337 Issue #27942: Fix memory leak in codeobject.c 2016-11-09 09:41:15 -05:00
Serhiy Storchaka 61dd7ff073 Issue #26906: Resolving special methods of uninitialized type now causes
implicit initialization of the type instead of a fail.
2016-10-08 12:24:09 +03:00
Serhiy Storchaka 6a35bf6ca0 Silenced compiler warnings. 2016-10-08 09:58:08 +03:00
Serhiy Storchaka 0ea51b18d5 Issue #18287: PyType_Ready() now checks that tp_name is not NULL.
Original patch by Niklas Koep.
2016-10-07 23:24:35 +03:00
Serhiy Storchaka ab8b75a56e Issue #28350: String constants with null character no longer interned. 2016-10-04 18:17:08 +03:00
Serhiy Storchaka 67edf73183 Issue #27942: String constants now interned recursively in tuples and frozensets. 2016-09-30 10:38:08 +03:00
Martin Panter ca56dd4767 Issue #28139: Fix messed up indentation
Also update the classmethod and staticmethod doc strings and comments to
match the RST documentation.
2016-09-17 07:54:55 +00:00
Martin Panter 440bbd0e38 Correct occurance → occurrence; extracted from patch by Georg Brandl 2016-09-08 05:22:16 +00:00
Martin Panter 6507657ddd Issue #27895: Spelling fixes (Contributed by Ville Skyttä). 2016-09-07 12:03:06 +00:00
Benjamin Peterson 89f676f30c promote some shifts to unsigned, so as not to invoke undefined behavior 2016-09-06 20:40:04 -07:00
Benjamin Peterson d4d7900307 make sure to not call memcpy with a NULL second argument 2016-09-06 17:58:25 -07:00
Mark Dickinson 02c0c0b6e7 Issue #27870: A left shift of zero by a large integer no longer attempts to allocate large amounts of memory. 2016-08-29 19:38:12 +01:00
Mark Dickinson 89446b2c91 Issue #25604: Fix bug in integer true division that could have resulted in off-by-one-ulp results in unusual cases. 2016-08-21 10:59:48 +01:00