Commit Graph

545 Commits

Author SHA1 Message Date
Raymond Hettinger c13516b0a0 merge 2013-10-01 01:00:59 -07:00
Raymond Hettinger 2ff2190b62 Issue #18594: Fix the fast path for collections.Counter().
The path wasn't being taken due to an over-restrictive type check.
2013-10-01 00:55:43 -07:00
Victor Stinner 33824f6fd7 Restore changeset 5bd9db528aed (issue #18408)
"Issue #18408: PyObject_Str(), PyObject_Repr() and type_call() now fail with an
assertion error if they are called with an exception set (PyErr_Occurred()).

As PyEval_EvalFrameEx(), they may clear the current exception and so the caller
looses its exception."
2013-08-26 14:05:19 +02:00
Antoine Pitrou 91541931f5 Back out 5bd9db528aed (issue #18408). It caused unsolved buildbot failures. 2013-08-23 23:18:20 +02:00
Antoine Pitrou 796564c27b Issue #18112: PEP 442 implementation (safe object finalization). 2013-07-30 19:59:21 +02:00
Christian Heimes de4d183955 Issue #18327: Fix argument order in call to compatible_for_assignment(oldto, newto, attr).
The fix only affects the error message of __class__ assignment. CID 983564
2013-07-20 14:19:46 +02:00
Victor Stinner 8e47832737 Issue #18408: PyObject_Str(), PyObject_Repr() and type_call() now fail with an
assertion error if they are called with an exception set (PyErr_Occurred()).

As PyEval_EvalFrameEx(), they may clear the current exception and so the caller
looses its exception.
2013-07-18 01:49:30 +02:00
Victor Stinner 5967bf4928 Issue #18408: Fix PyType_Ready(), handle _PyDict_SetItemId() failure 2013-07-17 22:01:37 +02:00
Victor Stinner 3997cfdb7f Cleanup type_call() to ease debug
It was easy to miss the call to type->tp_init because it was done in a long
conditional expression. Split the long expression in multiple lines to make the
debug step by step easier.
2013-07-16 22:51:21 +02:00
Victor Stinner 53510cda59 Issue #18408: type_new() and PyType_FromSpecWithBases() now raise MemoryError
on memory allocation failure
2013-07-15 19:34:20 +02:00
Victor Stinner a41f085144 Issue #18408: pmerge() help of mro_implementation() now raises MemoryError on
memory allocation failure

Replace also PyMem_Free() with PyMem_FREE() to be consistent with the rest of
the function.
2013-07-12 00:42:14 +02:00
Victor Stinner 2e8474ddde Issue #18408: slot_tp_str() must not fallback on slot_tp_repr() on error
type->tp_str must not point to slot_tp_str() if type has no __str__ attribute,
so there is no reason for slot_tp_str() to fallback on slot_tp_str() on lookup
error. Moreover, calling PyErr_Clear() may hide a real bug like MemoryError.

If __str__ attribute is removed, slots must be updated (which is done by
type_setattro()).
2013-07-11 22:46:11 +02:00
Victor Stinner 54e4ca76c9 typeobject.c: remove trailing spaces 2013-07-11 22:42:25 +02:00
Victor Stinner 9812af8e72 Issue #18408: Fix PyType_Ready() and type.__bases__ setter to handle
PyWeakref_NewRef() failure (ex: MemoryError).
2013-07-08 22:25:48 +02:00
Benjamin Peterson e1b4cbc422 when arguments are cells clear the locals slot (backport of #17927) 2013-05-14 22:31:26 -05:00
Benjamin Peterson 159ae41da6 when an argument is a cell, set the local copy to NULL (see #17927) 2013-05-12 18:16:06 -05:00
Guido van Rossum 6832c81d5d #17927: Keep frame from referencing cell-ified arguments. 2013-05-10 08:47:42 -07:00
Antoine Pitrou df6931dbbc Issue #17408: Avoid using an obsolete instance of the copyreg module when the interpreter is shutdown and then started again. 2013-05-04 20:46:19 +02:00
Antoine Pitrou 957a23b088 Issue #17408: Avoid using an obsolete instance of the copyreg module when the interpreter is shutdown and then started again. 2013-05-04 20:45:02 +02:00
Mark Dickinson 548677bb8c Issue #16447: Merge fix from 3.3. 2013-04-13 15:30:16 +01:00
Mark Dickinson 64aafeb4de Issue #16447: Fix potential segfault when setting __name__ on a class. 2013-04-13 15:26:58 +01:00
Benjamin Peterson d3f41fe121 merge 3.3 (#17610) 2013-04-01 17:43:30 -04:00
Benjamin Peterson 6395241471 list slotdefs in offset order rather than sorting them (closes #17610)
This means we can remove our usage of qsort() than relied on undefined behavior.
2013-04-01 17:41:41 -04:00
R David Murray aaf16b9cfb Merge: #7963: fix error message when 'object' called with arguments. 2013-02-18 21:44:03 -05:00
R David Murray 702a5dc1ed #7963: fix error message when 'object' called with arguments. 2013-02-18 21:39:18 -05:00
R David Murray 6b30759022 #7963: fix error message when 'object' called with arguments.
Patch by Alexander Belopolsky.
2013-02-18 21:20:08 -05:00
Andrew Svetlov 3ba3a3ee56 Issue #15422: get rid of PyCFunction_New macro 2012-12-25 13:32:35 +02:00
Andrew Svetlov 2cd8ce4690 Issue #9856: Replace deprecation warinigs to raising TypeError in object.__format__
Patch by Florent Xicluna.
2012-12-23 14:27:17 +02:00
Benjamin Peterson 3cb90241fc merge 3.3 2012-10-31 00:04:42 -04:00
Benjamin Peterson 2c05a2e01b do safety checks on __qualname__ assignment 2012-10-31 00:01:15 -04:00
Benjamin Peterson 8afa7fa510 don't shadow the __qualname__ descriptor with __qualname__ in the class's __dict__ (closes #16271) 2012-10-30 23:51:03 -04:00
Victor Stinner 4ca1cf35fb Issue #16086: PyTypeObject.tp_flags and PyType_Spec.flags are now unsigned
... (unsigned long and unsigned int) to avoid an undefined behaviour with
Py_TPFLAGS_TYPE_SUBCLASS ((1 << 31). PyType_GetFlags() result type is now
unsigned too (unsigned long, instead of long).
2012-10-30 23:40:45 +01:00
Trent Nelson da064d0745 Silence compiler warnings on Solaris 10 via explicit (void *) casts. 2012-09-18 22:00:25 -04:00
Trent Nelson ab02db23b1 Silence compiler warnings on Solaris 10 via explicit (void *) casts.
(Compiler: Solaris Studio 12.3)
2012-09-18 21:58:03 -04:00
Christian Heimes 76c082911b Fixed memory leak in error branch of object_repr which may leak a reference to mod when type_qualname returns NULL. CID 715371 2012-09-10 17:00:30 +02:00
Christian Heimes e81dc296f2 Fixed memory leak in error branch of object_repr which may leak a reference to mod when type_name returns NULL. CID 715371 2012-09-10 16:57:36 +02:00
Christian Heimes 455657961e Fixed possible reference leak to mod when type_name() returns NULL 2012-09-10 03:01:16 +02:00
Christian Heimes a0e7e41cba Fixed possible reference leak to mod when type_name() returns NULL 2012-09-10 03:00:14 +02:00
Antoine Pitrou 5b4faae307 Issue #13992: The trashcan mechanism is now thread-safe. This eliminates
sporadic crashes in multi-thread programs when several long deallocator
chains ran concurrently and involved subclasses of built-in container
types.

Note that the trashcan functions are part of the stable ABI, therefore
they have to be kept around for binary compatibility of extensions.
2012-09-06 01:17:42 +02:00
Antoine Pitrou 56cd62c04a Issue #13992: The trashcan mechanism is now thread-safe. This eliminates
sporadic crashes in multi-thread programs when several long deallocator
chains ran concurrently and involved subclasses of built-in container
types.

Because of this change, a couple extension modules compiled for 3.2.4
(those which use the trashcan mechanism, despite it being undocumented)
will not be loadable by 3.2.3 and earlier. However, extension modules
compiled for 3.2.3 and earlier will be loadable by 3.2.4.
2012-09-06 00:59:49 +02:00
Benjamin Peterson 6a42bd67d7 Make super() internal errors RuntimeError instead of SystemError (closes #15839) 2012-09-01 23:04:38 -04:00
Antoine Pitrou 721738fbee Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.
Patch by Serhiy Storchaka.
2012-08-15 23:20:39 +02:00
Antoine Pitrou 6f430e4963 Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.
Patch by Serhiy Storchaka.
2012-08-15 23:18:25 +02:00
Antoine Pitrou 66a3a7ed10 Try to fix crash on x86 OpenIndiana buildbot. 2012-06-24 00:42:59 +02:00
Antoine Pitrou 1351ca6e66 Replace assert() with a more informative fatal error. 2012-06-24 00:30:12 +02:00
Antoine Pitrou bb78f57c14 Use struct member (ht_type) instead of casting pointers. 2012-06-24 00:18:27 +02:00
Martin v. Löwis 9c56409d33 Issue #15146: Add PyType_FromSpecWithBases. Patch by Robin Schreiber. 2012-06-23 23:20:45 +02:00
Antoine Pitrou 99cc629969 Issue #15142: Fix reference leak when deallocating instances of types created using PyType_FromSpec(). 2012-06-23 14:42:38 +02:00
Antoine Pitrou a4db02c7a3 Issue #15142: Fix reference leak when deallocating instances of types created using PyType_FromSpec(). 2012-06-23 14:45:21 +02:00
Nick Coghlan 0b43bcf528 Close #14857: fix regression in references to PEP 3135 implicit __class__ closure variable. Reopens issue #12370, but also updates unittest.mock to workaround that issue 2012-05-27 18:17:07 +10:00