summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* bpo-29590: fix stack trace for gen.throw() with yield from (GH-19896)Miss Islington (bot)2020-09-041-0/+10
| | | | | | | | | | | * Add failing test. * bpo-29590: fix stack trace for gen.throw() with yield from (GH-NNNN) When gen.throw() is called on a generator after a "yield from", the intermediate stack trace entries are lost. This commit fixes that. (cherry picked from commit 8b33961e4bc4020d8b2d5b949ad9d5c669300e89) Co-authored-by: Chris Jerdonek <chris.jerdonek@gmail.com>
* [3.9] bpo-41654: Fix deallocator of MemoryError to account for subclasses ↵Pablo Galindo2020-09-011-2/+12
| | | | | | | | | | | | (GH-22020) (GH-22045) When allocating MemoryError classes, there is some logic to use pre-allocated instances in a freelist only if the type that is being allocated is not a subclass of MemoryError. Unfortunately in the destructor this logic is not present so the freelist is altered even with subclasses of MemoryError.. (cherry picked from commit 9b648a95ccb4c3b14f1e87158f5c9f5dbb2f62c0) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-41295: Reimplement the Carlo Verre "hackcheck" (GH-21528)Miss Islington (bot)2020-07-181-7/+20
| | | | | | | | Walk down the MRO backwards to find the type that originally defined the final `tp_setattro`, then make sure we are not jumping over intermediate C-level bases with the Python-level call. Automerge-Triggered-By: @gvanrossum (cherry picked from commit c53b310e5926266ce267c44a168165cacd786d6e) Co-authored-by: scoder <stefan_ml@behnel.de>
* bpo-41175: Guard against a NULL pointer dereference within bytearrayobject ↵Miss Islington (bot)2020-07-101-1/+3
| | | | | | | | | | (GH-21240) The issue is triggered by the bytearray() + bytearray() operation. Detected by GCC 10 static analysis tool. (cherry picked from commit 61fc23ca106bc82955b0e59d1ab42285b94899e2) Co-authored-by: stratakis <cstratak@redhat.com>
* bpo-39960: Allow heap types in the "Carlo Verre" hack check that override ↵Miss Islington (bot)2020-07-031-11/+30
| | | | | | | | "tp_setattro()" (GH-21092) Automerge-Triggered-By: @gvanrossum (cherry picked from commit 148f32913573c29250dfb3f0d079eb8847633621) Co-authored-by: scoder <stefan_ml@behnel.de>
* bpo-40824: Do not mask errors in __iter__ in "in" and the operator module. ↵Miss Islington (bot)2020-06-221-1/+3
| | | | | | | | | | (GH-20537) Unexpected errors in calling the __iter__ method are no longer masked by TypeError in the "in" operator and functions operator.contains(), operator.indexOf() and operator.countOf(). (cherry picked from commit cafe1b6e9d3594a34aba50e872d4198296ffaadf) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-36346: Add Py_DEPRECATED to deprecated unicode APIs (GH-20878)Inada Naoki2020-06-181-0/+23
| | | | | Co-authored-by: Kyle Stanley <aeros167@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> (cherry picked from commit 2c4928d37edc5e4aeec3c0b79fa3460b1ec9b60d)
* bpo-40703: Let PyType_FromSpec() set "type.__module__" only if it is not set ↵Miss Islington (bot)2020-06-101-15/+20
| | | | | yet. (GH-20273) (GH-20782) (cherry picked from commit 24b8bad6d30ae4fb37ee686a073adfa5308659f9)
* bpo-40724: Support setting buffer slots from type specs (GH-20648) (GH-20683)Miss Islington (bot)2020-06-071-2/+2
| | | | This is not part of the limited API but makes the buffer slots available for type specs. (cherry picked from commit f7c4e236429606e1c982cacf24e10fc86ef4462f)
* bpo-40217: Ensure Py_VISIT(Py_TYPE(self)) is always called for ↵Miss Islington (bot)2020-05-282-93/+11
| | | | | | | | | | | | PyType_FromSpec types (reverts GH-19414) (GH-20264) Heap types now always visit the type in tp_traverse. See added docs for details. This reverts commit 0169d3003be3d072751dd14a5c84748ab63a249f. Automerge-Triggered-By: @encukou (cherry picked from commit 1cf15af9a6f28750f37b08c028ada31d38e818dd) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* Remove spurious NULL in descrobject.c (GH-20344)Miss Islington (bot)2020-05-241-1/+0
| | | | | | Co-authored-by: hai shi <shihai1991@126.com> (cherry picked from commit 3f5f61409ebf95fa606bcbb15dfaaadad6084dc6) Co-authored-by: Hai Shi <shihai1992@gmail.com>
* bpo-40696: Fix a hang that can arise after gen.throw() (GH-20287)Miss Islington (bot)2020-05-221-4/+6
| | | | | | | | | | This updates _PyErr_ChainStackItem() to use _PyErr_SetObject() instead of _PyErr_ChainExceptions(). This prevents a hang in certain circumstances because _PyErr_SetObject() performs checks to prevent cycles in the exception context chain while _PyErr_ChainExceptions() doesn't. (cherry picked from commit 7c30d12bd5359b0f66c4fbc98aa055398bcc8a7e) Co-authored-by: Chris Jerdonek <chris.jerdonek@gmail.com>
* [3.9] bpo-40514: Remove --with-experimental-isolated-subinterpreters in 3.9 ↵Victor Stinner2020-05-196-40/+4
| | | | | | | (GH-20228) Remove --with-experimental-isolated-subinterpreters configure option in Python 3.9: the experiment continues in the master branch, but it's no longer needed in 3.9.
* Use _PyErr_ChainStackItem() inside gen_send_ex(). (GH-20173) (#20202)Miss Islington (bot)2020-05-191-10/+2
| | | | | | | | _PyErr_ChainStackItem was just added in GH-19951 (for bpo-31033). (cherry picked from commit ff7a8b03c49153021d6de5d0b2fa8b5163059ed6) Co-authored-by: Chris Jerdonek <chris.jerdonek@gmail.com> Co-authored-by: Chris Jerdonek <chris.jerdonek@gmail.com>
* bpo-31033: Improve the traceback for cancelled asyncio tasks (GH-19951)Chris Jerdonek2020-05-181-17/+3
| | | | | When an asyncio.Task is cancelled, the exception traceback now starts with where the task was first interrupted. Previously, the traceback only had "depth one."
* bpo-39075: types.SimpleNamespace no longer sorts attributes in its repr ↵Zackery Spytz2020-05-161-2/+0
| | | | (GH-19430)
* bpo-40521: Add PyInterpreterState.unicode (GH-20081)Victor Stinner2020-05-131-31/+33
| | | | | | | Move PyInterpreterState.fs_codec into a new PyInterpreterState.unicode structure. Give a name to the fs_codec structure and use this structure in unicodeobject.c.
* bpo-29587: Make gen.throw() chain exceptions with yield from (GH-19858)Chris Jerdonek2020-05-131-10/+12
| | | | | | | | | | | | The previous commits on bpo-29587 got exception chaining working with gen.throw() in the `yield` case. This patch also gets the `yield from` case working. As a consequence, implicit exception chaining now also works in the asyncio scenario of awaiting on a task when an exception is already active. Tests are included for both the asyncio case and the pure generator-only case.
* bpo-39465: Remove _PyUnicode_ClearStaticStrings() from C API (GH-20078)Victor Stinner2020-05-131-3/+3
| | | | Remove the _PyUnicode_ClearStaticStrings() function from the C API. Make the function fully private (declare it with "static").
* bpo-38787: Add PyCFunction_CheckExact() macro for exact type checks (GH-20024)scoder2020-05-121-1/+1
| | | | | … now that we allow subtypes of PyCFunction. Also add PyCMethod_CheckExact() and PyCMethod_Check() for checks against the PyCMethod subtype.
* bpo-40596: Fix str.isidentifier() for non-canonicalized strings containing ↵Serhiy Storchaka2020-05-121-4/+22
| | | | non-BMP characters on Windows. (GH-20053)
* bpo-40593: Improve syntax errors for invalid characters in source code. ↵Serhiy Storchaka2020-05-121-23/+41
| | | | (GH-20033)
* bpo-39465: Don't access directly _Py_Identifier members (GH-20043)Victor Stinner2020-05-112-8/+8
| | | | | * Replace id->object with _PyUnicode_FromId(&id) * Use _Py_static_string_init(str) macro to initialize statically name_op in typeobject.c.
* bpo-40584: Update PyType_FromModuleAndSpec() to process tp_vectorcall_offset ↵Hai Shi2020-05-111-2/+12
| | | | (GH-20026)
* bpo-40575: Avoid unnecessary overhead in _PyDict_GetItemIdWithError() (GH-20018)scoder2020-05-111-1/+3
| | | | | Avoid unnecessary overhead in _PyDict_GetItemIdWithError() by calling _PyDict_GetItem_KnownHash() instead of the more generic PyDict_GetItemWithError(), since we already know the hash of interned strings.
* Improve code clarity for the set lookup logic (GH-20028)Raymond Hettinger2020-05-101-125/+55
|
* bpo-37986: Improve perfomance of PyLong_FromDouble() (GH-15611)Sergey Fedoseev2020-05-102-23/+17
| | | | | | | | | * bpo-37986: Improve perfomance of PyLong_FromDouble() * Use strict bound check for safety and symmetry * Remove possibly outdated performance claims Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* bpo-40273: Reversible mappingproxy (FH-19513)Zackery Spytz2020-05-081-0/+9
|
* bpo-38787: C API for module state access from extension methods (PEP 573) ↵Petr Viktorin2020-05-074-12/+182
| | | | | | | | | (GH-19936) Module C state is now accessible from C-defined heap type methods (PEP 573). Patch by Marcel Plch and Petr Viktorin. Co-authored-by: Marcel Plch <mplch@redhat.com> Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-40521: Disable list free list in subinterpreters (GH-19959)Victor Stinner2020-05-061-1/+8
| | | | | | When Python is built with experimental isolated interpreters, disable the list free list. Temporary workaround until this cache is made per-interpreter.
* bpo-40521: Disable method cache in subinterpreters (GH-19960)Victor Stinner2020-05-061-3/+19
| | | | | | When Python is built with experimental isolated interpreters, disable the type method cache. Temporary workaround until the cache is made per-interpreter.
* bpo-40523: Add pass-throughs for hash() and reversed() to weakref.proxy ↵Pablo Galindo2020-05-051-1/+18
| | | | objects (GH-19946)
* bpo-40521: Disable free lists in subinterpreters (GH-19937)Victor Stinner2020-05-053-80/+162
| | | | | | | | | When Python is built with experimental isolated interpreters, disable tuple, dict and free free lists. Temporary workaround until these caches are made per-interpreter. Add frame_alloc() and frame_get_builtins() subfunctions to simplify _PyFrame_New_NoTrack().
* bpo-40521: Disable Unicode caches in isolated subinterpreters (GH-19933)Victor Stinner2020-05-052-15/+79
| | | | | | | When Python is built in the experimental isolated subinterpreters mode, disable Unicode singletons and Unicode interned strings since they are shared by all interpreters. Temporary workaround until these caches are made per-interpreter.
* bpo-29587: _PyErr_ChainExceptions() checks exception (GH-19902)Victor Stinner2020-05-052-20/+34
| | | | | | | | | | | | | | | | | | | _PyErr_ChainExceptions() now ensures that the first parameter is an exception type, as done by _PyErr_SetObject(). * The following function now check PyExceptionInstance_Check() in an assertion using a new _PyBaseExceptionObject_cast() helper function: * PyException_GetTraceback(), PyException_SetTraceback() * PyException_GetCause(), PyException_SetCause() * PyException_GetContext(), PyException_SetContext() * PyExceptionClass_Name() now checks PyExceptionClass_Check() with an assertion. * Remove XXX comment and add gi_exc_state variable to _gen_throw(). * Remove comment from test_generators
* bpo-40455: Remove gcc10 warning about x_digits (#19852)Dong-hee Na2020-05-041-4/+3
| | | | | | | * bpo-40455: Remove gcc10 warning about x_digits * bpo-40455: nit * bpo-40455: fix logic error
* bpo-39573: Use Py_IS_TYPE to check for types (GH-19882)Hai Shi2020-05-042-3/+3
|
* bpo-40408: Fix support of nested type variables in GenericAlias. (GH-19836)Serhiy Storchaka2020-05-041-19/+104
|
* Remove out-of-date comment (GH-19886)Raymond Hettinger2020-05-031-2/+1
|
* Simplify set entry insertion logic. (GH-19881)Raymond Hettinger2020-05-031-16/+2
|
* bpo-29587: allow chaining NULL exceptions in _gen_throw() (GH-19877)Chris Jerdonek2020-05-031-4/+5
| | | | | | | | | | | | | This is a follow-up to GH-19823 that removes the check that the exception value isn't NULL, prior to calling _PyErr_ChainExceptions(). This enables implicit exception chaining for gen.throw() in more circumstances. The commit also adds a test that a particular code snippet involving gen.throw() doesn't crash. The test shows why the new `gi_exc_state.exc_type != Py_None` check that was added is necessary. Without the new check, the code snippet (as well as a number of other tests) crashes on certain platforms (e.g. Fedora but not Mac).
* bpo-29587: Update gen.throw() to chain exceptions (#19823)Chris Jerdonek2020-05-021-0/+9
| | | | | | | Before this commit, if an exception was active inside a generator when calling gen.throw(), that exception was lost (i.e. there was no implicit exception chaining). This commit fixes that by setting exc.__context__ when calling gen.throw(exc).
* Revert "bpo-29587: Enable implicit exception chaining with gen.throw() ↵Victor Stinner2020-04-301-6/+0
| | | | | (GH-19811)" (#19821) This reverts commit 2514a632fb7d37be24c2059d0e286d35600f9795.
* bpo-29587: Enable implicit exception chaining with gen.throw() (GH-19811)Chris Jerdonek2020-04-301-0/+6
| | | | | Before this commit, if an exception was active inside a generator when calling gen.throw(), then that exception was lost (i.e. there was no implicit exception chaining). This commit fixes that.
* bpo-40228: More robust frame.setlineno. (GH-19437)Mark Shannon2020-04-291-312/+251
| | | More robust frame.setlineno. Makes no assumptions about source->bytecode translation.
* bpo-40421: Add PyFrame_GetBack() function (GH-19765)Victor Stinner2020-04-291-0/+10
| | | | | | New PyFrame_GetBack() function: get the frame next outer frame. Replace frame->f_back with PyFrame_GetBack(frame) in most code but frameobject.c, ceval.c and genobject.c.
* bpo-40429: PyThreadState_GetFrame() returns a strong ref (GH-19781)Victor Stinner2020-04-291-4/+5
| | | | The PyThreadState_GetFrame() function now returns a strong reference to the frame.
* bpo-40428: Remove PyTuple_ClearFreeList() function (GH-19769)Victor Stinner2020-04-297-51/+25
| | | | | | | | | | | | | | | | | | | Remove the following function from the C API: * PyAsyncGen_ClearFreeLists() * PyContext_ClearFreeList() * PyDict_ClearFreeList() * PyFloat_ClearFreeList() * PyFrame_ClearFreeList() * PyList_ClearFreeList() * PySet_ClearFreeList() * PyTuple_ClearFreeList() Make these functions private, move them to the internal C API and change their return type to void. Call explicitly PyGC_Collect() to free all free lists. Note: PySet_ClearFreeList() did nothing.
* bpo-40429: Refactor super_init() (GH-19776)Victor Stinner2020-04-291-64/+85
| | | | Add super_init_without_args() sub-function. Hold a strong reference to the frame code object while calling super_init_without_args().
* bpo-40429: PyFrame_GetCode() now returns a strong reference (GH-19773)Victor Stinner2020-04-282-2/+3
|