summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* bpo-42990: Further refactoring of PyEval_ functions. (GH-24368)Mark Shannon2021-02-013-101/+31
| | | | | | | | | | * Further refactoring of PyEval_EvalCode and friends. Break into make-frame, and eval-frame parts. * Simplify function vector call using new _PyEval_Vector. * Remove unused internal functions: _PyEval_EvalCodeWithName and _PyEval_EvalCode. * Don't use legacy function PyEval_EvalCodeEx.
* bpo-40455: Fix gcc10+ warning about writing into a section of offset 0 ↵Pablo Galindo2021-01-301-2/+2
| | | | (GH-24384)
* bpo-42979: Use _Py_CheckSlotResult() to check slots result (GH-24356)Victor Stinner2021-01-292-191/+288
| | | | | | | | | | | | | | | When Python is built in debug mode (with C assertions), calling a type slot like sq_length (__len__() in Python) now fails with a fatal error if the slot succeeded with an exception set, or failed with no exception set. The error message contains the slot, the type name, and the current exception (if an exception is set). * Check the result of all slots using _Py_CheckSlotResult(). * No longer pass op_name to ternary_op() in release mode. * Replace operator with dunder Python method name in error messages. For example, replace "*" with "__mul__". * Fix compiler_exit_scope() when an exception is set. * Fix bytearray.extend() when an exception is set: don't call bytearray_setslice() with an exception set.
* bpo-42990: Introduce 'frame constructor' struct to simplify API for ↵Mark Shannon2021-01-293-80/+51
| | | | | | | PyEval_CodeEval and friends (GH-24298) * Introduce 'frame constructor' to simplify API for frame creation * Embed struct using a macro to conform to PEP 7
* bpo-42979: Enhance abstract.c assertions checking slot result (GH-24352)Victor Stinner2021-01-272-14/+39
| | | | | | | | * bpo-42979: Enhance abstract.c assertions checking slot result Add _Py_CheckSlotResult() function which fails with a fatal error if a slot function succeeded with an exception set or failed with no exception set: write the slot name, the type name and the current exception (if an exception is set).
* bpo-42923: Dump extension modules on fatal error (GH-24207)Victor Stinner2021-01-181-0/+13
| | | | | | | The Py_FatalError() function and the faulthandler module now dump the list of extension modules on a fatal error. Add _Py_DumpExtensionModules() and _PyModule_IsExtension() internal functions.
* bpo-42924: Fix incorrect copy in bytearray_repeat (GH-24208)Tobias Holl2021-01-131-2/+4
| | | | Before, using the * operator to repeat a bytearray would copy data from the start of the internal buffer (ob_bytes) and not from the start of the actual data (ob_start).
* bpo-42823: Fix frame lineno when frame.f_trace is set (GH-24099)Mark Shannon2021-01-052-8/+7
| | | | | | | | | * Add test for frame.f_lineno with/without tracing. * Make sure that frame.f_lineno is correct regardless of whether frame.f_trace is set. * Update importlib * Add NEWS
* bpo-42814: Fix undefined behavior in Objects/genericaliasobject.c (GH-24073)Zackery Spytz2021-01-031-1/+1
| | | | | In is_typing_name(), va_end() is not always called before the function returns. It is undefined behavior to call va_start() without also calling va_end().
* bpo-42195: Disallow isinstance/issubclass for subclasses of genericaliases ↵Ken Jin2021-01-021-1/+1
| | | | | | | | | | | | | | in Union (GH-24059) Previously this didn't raise an error. Now it will: ```python from collections.abc import Callable isinstance(int, list | Callable[..., str]) ``` Also added tests in Union since there were previously none for stuff like ``isinstance(list, list | list[int])`` either. Backport to 3.9 not required. Automerge-Triggered-By: GH:gvanrossum
* bpo-27794: Add `name` attribute to `property` class (GH-23967)Yurii Karabas2020-12-301-4/+48
|
* bpo-40052: Fix alignment issue in PyVectorcall_Function() (GH-23999)Petr Viktorin2020-12-291-1/+2
| | | | | | | | | | | | | | | ``` In file included from /usr/include/python3.8/Python.h:147: In file included from /usr/include/python3.8/abstract.h:837: /usr/include/python3.8/cpython/abstract.h:91:11: error: cast from 'char *' to 'vectorcallfunc *' (aka 'struct _object *(**)(struct _object *, struct _object *const *, unsigned long, struct _object *)') increases required alignment from 1 to 8 [-Werror,-Wcast-align] ptr = (vectorcallfunc*)(((char *)callable) + offset); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. ``` Co-Authored-By: Andreas Schneider <asn@cryptomilk.org> Co-Authored-By: Antoine Pitrou <antoine@python.org>
* Fix compiler warnings regarding loss of data (GH-23983)Pablo Galindo2020-12-291-1/+1
|
* bpo-42745: finalize_interp_types() calls _PyType_Fini() (GH-23953)Victor Stinner2020-12-262-5/+6
| | | | | Call _PyType_Fini() in subinterpreters. Fix reference leaks in subinterpreters.
* bpo-40521: Per-interpreter interned strings (GH-20085)Victor Stinner2020-12-262-83/+28
| | | | | | | | | | | Make the Unicode dictionary of interned strings compatible with subinterpreters. Remove the INTERN_NAME_STRINGS macro in typeobject.c: names are always now interned (even if EXPERIMENTAL_ISOLATED_SUBINTERPRETERS macro is defined). _PyUnicode_ClearInterned() now uses PyDict_Next() to no longer allocate memory, to ensure that the interned dictionary is cleared.
* bpo-42745: Make the type cache per-interpreter (GH-23947)Victor Stinner2020-12-261-80/+98
| | | | | | | | | | | Make the type attribute lookup cache per-interpreter. Add private _PyType_InitCache() function, called by PyInterpreterState_New(). Continue to share next_version_tag between interpreters, since static types are still shared by interpreters. Remove MCACHE macro: the cache is no longer disabled if the EXPERIMENTAL_ISOLATED_SUBINTERPRETERS macro is defined.
* bpo-39465: Fix _PyUnicode_FromId() for subinterpreters (GH-20058)Victor Stinner2020-12-251-23/+62
| | | | | | | | | | | | | | | | | Make _PyUnicode_FromId() function compatible with subinterpreters. Each interpreter now has an array of identifier objects (interned strings decoded from UTF-8). * Add PyInterpreterState.unicode.identifiers: array of identifiers objects. * Add _PyRuntimeState.unicode_ids used to allocate unique indexes to _Py_Identifier. * Rewrite the _Py_Identifier structure. Microbenchmark on _PyUnicode_FromId(&PyId_a) with _Py_IDENTIFIER(a): [ref] 2.42 ns +- 0.00 ns -> [atomic] 3.39 ns +- 0.00 ns: 1.40x slower This change adds 1 ns per _PyUnicode_FromId() call in average.
* bpo-41559: Implement PEP 612 - Add ParamSpec and Concatenate to typing (#23702)kj2020-12-241-14/+62
|
* bpo-42195: Ensure consistency of Callable's __args__ in collections.abc and ↵kj2020-12-132-24/+42
| | | | typing (GH-23060)
* bpo-42576: Raise TypeError when passing in keyword arguments to GenericAlias ↵kj2020-12-051-1/+1
| | | | | | | | | (GH-23656) Use `_PyArg_NoKeywords` instead of `_PyArg_NoKwnames` when checking the `kwds` tuple when creating `GenericAlias`. This fixes an interpreter crash when passing in keyword arguments to `GenericAlias`'s constructor. Needs backport to 3.9. Automerge-Triggered-By: GH:gvanrossum
* bpo-42536: GC track recycled tuples (GH-23623)Brandt Bucher2020-12-053-0/+26
| | | | | | | | | | | | | | | | Several built-in and standard library types now ensure that their internal result tuples are always tracked by the garbage collector: - collections.OrderedDict.items - dict.items - enumerate - functools.reduce - itertools.combinations - itertools.combinations_with_replacement - itertools.permutations - itertools.product - itertools.zip_longest - zip Previously, they could have become untracked by a prior garbage collection.
* bpo-42431: Fix outdated bytes comments (GH-23458)Serhiy Storchaka2020-12-035-35/+21
| | | | Also move definitions of internal macros F_LJUST etc to private header.
* bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587)Victor Stinner2020-12-0113-45/+45
| | | | | | | | | No longer use deprecated aliases to functions: * Replace PyObject_MALLOC() with PyObject_Malloc() * Replace PyObject_REALLOC() with PyObject_Realloc() * Replace PyObject_FREE() with PyObject_Free() * Replace PyObject_Del() with PyObject_Free() * Replace PyObject_DEL() with PyObject_Free()
* bpo-42519: Replace PyMem_MALLOC() with PyMem_Malloc() (GH-23586)Victor Stinner2020-12-0111-53/+53
| | | | | | | | | | | No longer use deprecated aliases to functions: * Replace PyMem_MALLOC() with PyMem_Malloc() * Replace PyMem_REALLOC() with PyMem_Realloc() * Replace PyMem_FREE() with PyMem_Free() * Replace PyMem_Del() with PyMem_Free() * Replace PyMem_DEL() with PyMem_Free() Modify also the PyMem_DEL() macro to use directly PyMem_Free().
* bpo-42202: Store func annotations as a tuple (GH-23316)Yurii Karabas2020-11-251-0/+19
| | | | | | | | | | | | | Reduce memory footprint and improve performance of loading modules having many func annotations. >>> sys.getsizeof({"a":"int","b":"int","return":"int"}) 232 >>> sys.getsizeof(("a","int","b","int","return","int")) 88 The tuple is converted into dict on the fly when `func.__annotations__` is accessed first. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Inada Naoki <songofacandy@gmail.com>
* bpo-40170: Hide impl detail of Py_TRASHCAN_BEGIN macro (GH-23235)Hai Shi2020-11-241-0/+9
| | | | | The Py_TRASHCAN_BEGIN macro no longer accesses PyTypeObject attributes, but now can get the condition by calling the new private _PyTrash_cond() function which hides implementation details.
* bpo-42435: Speed up comparison of bytes and bytearray object (GH--23461)Serhiy Storchaka2020-11-222-33/+12
| | | | | * Speed up comparison of bytes objects with non-bytes objects when option -b is specified. * Speed up comparison of bytarray objects with non-buffer object.
* bpo-42423: Accept single base class in PyType_FromModuleAndSpec() (GH-23441)Serhiy Storchaka2020-11-222-10/+4
|
* bpo-42425: Fix possible leak in initialization of errmap for OSError (GH-23446)Serhiy Storchaka2020-11-211-1/+3
|
* bpo-42412: Fix possible leaks and check arguments in ↵Serhiy Storchaka2020-11-211-5/+18
| | | | | | | | PyType_FromModuleAndSpec() (GH-23410) * There were leaks if Py_tp_bases is used more than once or if some call is failed before setting tp_bases. * There was a crash if the bases argument or the Py_tp_bases slot is not a tuple. * The documentation was not accurate.
* bpo-40998: Address compiler warnings found by ubsan (GH-20929)Christian Heimes2020-11-181-1/+5
| | | | | Signed-off-by: Christian Heimes <christian@python.org> Automerge-Triggered-By: GH:tiran
* bpo-42332: Add weakref slot to types.GenericAlias (GH-23250)kj2020-11-161-0/+6
| | | Automerge-Triggered-By: GH:gvanrossum
* bpo-42246: Partial implementation of PEP 626. (GH-23113)Mark Shannon2020-11-124-123/+435
| | | * Implement new line number table format, as defined in PEP 626.
* bpo-40170: Fix PyType_Ready() refleak on static type (GH-23236)Victor Stinner2020-11-111-2/+7
| | | | | | | | | bpo-1635741, bpo-40170: When called on a static type with NULL tp_base, PyType_Ready() no longer increments the reference count of the PyBaseObject_Type ("object). PyTypeObject.tp_base is a strong reference on a heap type, but it is borrowed reference on a static type. Fix 99 reference leaks at Python exit (showrefcount 18623 => 18524).
* bpo-41073: PyType_GetSlot() can now accept static types. (GH-21931)Hai Shi2020-11-103-97/+137
| | | | | | | PyType_GetSlot() can now accept static types. Co-Authored-By: Petr Viktorin <encukou@gmail.com> Automerge-Triggered-By: GH:encukou
* bpo-42085: Introduce dedicated entry in PyAsyncMethods for sending values ↵Vladimir Matveev2020-11-104-31/+60
| | | | (#22780)
* Fix typo in unicodeobject.c (GH-23180)Ikko Ashimine2020-11-101-1/+1
| | | | | exeeds -> exceeds Automerge-Triggered-By: GH:Mariatta
* bpo-42233: Add union type expression support for GenericAlias and fix ↵kj2020-11-093-17/+23
| | | | de-duplicating of GenericAlias (GH-23077)
* bpo-41832: PyType_FromModuleAndSpec() now accepts NULL tp_doc (GH-23123)Hai Shi2020-11-061-0/+4
|
* bpo-42262: Add Py_NewRef() and Py_XNewRef() (GH-23152)Victor Stinner2020-11-051-0/+16
| | | | Added Py_NewRef() and Py_XNewRef() functions to increment the reference count of an object and return the object.
* Add _PyType_GetModuleByDef (GH-22835)Petr Viktorin2020-11-031-0/+38
| | | | | See https://mail.python.org/archives/list/capi-sig@python.org/thread/T3P2QNLNLBRFHWSKYSTPMVEIL2EEKFJU/ for discussion. https://bugs.python.org/issue42100
* bpo-42143: Ensure PyFunction_NewWithQualName() can't fail after creating the ↵Yonatan Goldschmidt2020-10-291-13/+16
| | | | | | func object (GH-22953) func_dealloc() does not handle partially-created objects. Best not to give it any.
* bpo-42161: Remove private _PyLong_Zero and _PyLong_One (GH-23003)Victor Stinner2020-10-271-18/+0
| | | | | Use PyLong_FromLong(0) and PyLong_FromLong(1) of the public C API instead. For Python internals, _PyLong_GetZero() and _PyLong_GetOne() of pycore_long.h can be used.
* bpo-42099: Fix reference to ob_type in unionobject.c and ceval (GH-22829)Neil Schemenauer2020-10-271-1/+1
| | | * Use Py_TYPE() rather than o->ob_type.
* bpo-42161: Use _PyLong_GetZero() and _PyLong_GetOne() (GH-22995)Victor Stinner2020-10-277-36/+61
| | | | Use _PyLong_GetZero() and _PyLong_GetOne() in Objects/ and Python/ directories.
* bpo-42161: Add _PyLong_GetZero() and _PyLong_GetOne() (GH-22993)Victor Stinner2020-10-261-23/+14
| | | | | | Add _PyLong_GetZero() and _PyLong_GetOne() functions and a new internal pycore_long.h header file. Python cannot be built without small integer singletons anymore.
* bpo-42157: unicodedata avoids references to UCD_Type (GH-22990)Victor Stinner2020-10-261-2/+1
| | | | | | | | | | * UCD_Check() uses PyModule_Check() * Simplify the internal _PyUnicode_Name_CAPI structure: * Remove size and state members * Remove state and self parameters of getcode() and getname() functions * Remove global_module_state
* bpo-1635741: _PyUnicode_Name_CAPI moves to internal C API (GH-22713)Victor Stinner2020-10-261-15/+16
| | | | | | | | | | The private _PyUnicode_Name_CAPI structure of the PyCapsule API unicodedata.ucnhash_CAPI moves to the internal C API. Moreover, the structure gets a new state member which must be passed to the getcode() and getname() functions. * Move Include/ucnhash.h to Include/internal/pycore_ucnhash.h * unicodedata module is now built with Py_BUILD_CORE_MODULE. * unicodedata: move hashAPI variable into unicodedata_module_state.
* bpo-42152: Use PyDict_Contains and PyDict_SetDefault if appropriate. (GH-22986)Serhiy Storchaka2020-10-262-94/+73
| | | | | | | If PyDict_GetItemWithError is only used to check whether the key is in dict, it is better to use PyDict_Contains instead. And if it is used in combination with PyDict_SetItem, PyDict_SetDefault can replace the combination.
* bpo-42006: Stop using PyDict_GetItem, PyDict_GetItemString and ↵Serhiy Storchaka2020-10-265-51/+118
| | | | | | | | | | | _PyDict_GetItemId. (GH-22648) These functions are considered not safe because they suppress all internal errors and can return wrong result. PyDict_GetItemString and _PyDict_GetItemId can also silence current exception in rare cases. Remove no longer used _PyDict_GetItemId. Add _PyDict_ContainsId and rename _PyDict_Contains into _PyDict_Contains_KnownHash.