summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
...
* gh-113750: Fix object resurrection in free-threaded builds (gh-113751)Sam Gross2024-01-061-3/+12
| | | | | | | | | gh-113750: Fix object resurrection on free-threaded builds This avoids the undesired re-initializing of fields like `ob_gc_bits`, `ob_mutex`, and `ob_tid` when an object is resurrected due to its finalizer being called. This change has no effect on the default (with GIL) build.
* gh-112532: Tag mimalloc heaps and pages (#113742)Sam Gross2024-01-054-13/+30
| | | | | | | | | | | | | | | | | | | | | * gh-112532: Tag mimalloc heaps and pages Mimalloc pages are data structures that contain contiguous allocations of the same block size. Note that they are distinct from operating system pages. Mimalloc pages are contained in segments. When a thread exits, it abandons any segments and contained pages that have live allocations. These segments and pages may be later reclaimed by another thread. To support GC and certain thread-safety guarantees in free-threaded builds, we want pages to only be reclaimed by the corresponding heap in the claimant thread. For example, we want pages containing GC objects to only be claimed by GC heaps. This allows heaps and pages to be tagged with an integer tag that is used to ensure that abandoned pages are only claimed by heaps with the same tag. Heaps can be initialized with a tag (0-15); any page allocated by that heap copies the corresponding tag. * Fix conversion warning
* gh-112532: Isolate abandoned segments by interpreter (#113717)Sam Gross2024-01-042-58/+44
| | | | | | | | | | | | | | | * gh-112532: Isolate abandoned segments by interpreter Mimalloc segments are data structures that contain memory allocations along with metadata. Each segment is "owned" by a thread. When a thread exits, it abandons its segments to a global pool to be later reclaimed by other threads. This changes the pool to be per-interpreter instead of process-wide. This will be important for when we use mimalloc to find GC objects in the `--disable-gil` builds. We want heaps to only store Python objects from a single interpreter. Absent this change, the abandoning and reclaiming process could break this isolation. * Add missing '&_mi_abandoned_default' to 'tld_empty'
* Document the `co_lines` method on code objects (#113682)Alex Waygood2024-01-031-1/+1
| | | Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
* gh-111178: Avoid calling functions from incompatible pointer types in ↵Christopher Chavez2024-01-021-100/+126
| | | | | dictobject.c (#112892) Fix undefined behavior warnings (UBSan -fsanitize=function).
* gh-111178: Avoid calling functions from incompatible pointer types in ↵Christopher Chavez2024-01-021-106/+147
| | | | | | | | | | descrobject.c (GH-112861) Fix undefined behavior warnings (UBSan -fsanitize=function), for example: Python/generated_cases.c.h:3315:13: runtime error: call to function mappingproxy_dealloc through pointer to incorrect function type 'void (*)(struct _object *)' descrobject.c:1160: note: mappingproxy_dealloc defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/generated_cases.c.h:3315:13 in
* gh-111178: Avoid calling functions from incompatible pointer types in ↵Christopher Chavez2024-01-021-72/+92
| | | | | | | | | | listobject.c (GH-112820) Fix undefined behavior warnings (UBSan -fsanitize=function), for example: Objects/object.c:674:11: runtime error: call to function list_repr through pointer to incorrect function type 'struct _object *(*)(struct _object *)' listobject.c:382: note: list_repr defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:674:11 in
* gh-112532: Use separate mimalloc heaps for GC objects (gh-113263)Sam Gross2023-12-263-22/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | * gh-112532: Use separate mimalloc heaps for GC objects In `--disable-gil` builds, we now use four separate heaps in anticipation of using mimalloc to find GC objects when the GIL is disabled. To support this, we also make a few changes to mimalloc: * `mi_heap_t` and `mi_tld_t` initialization is split from allocation. This allows us to have a `mi_tld_t` per-`PyThreadState`, which is important to keep interpreter isolation, since the same OS thread may run in multiple interpreters (using different PyThreadStates.) * Heap abandoning (mi_heap_collect_ex) can now be called from a different thread than the one that created the heap. This is necessary because we may clear and delete the containing PyThreadStates from a different thread during finalization and after fork(). * Use enum instead of defines and guard mimalloc includes. * The enum typedef will be convenient for future PRs that use the type. * Guarding the mimalloc includes allows us to unconditionally include pycore_mimalloc.h from other header files that rely on things like `struct _mimalloc_thread_state`. * Only define _mimalloc_thread_state in Py_GIL_DISABLED builds
* gh-111971: Make _PyUnicode_FromId thread-safe in --disable-gil (gh-113489)Donghee Na2023-12-261-3/+7
|
* gh-113212: Improve error message & document zero-arg super inside nested ↵Yan Yanchii2023-12-221-3/+16
| | | | functions and generator expressions (GH-113307)
* gh-112027: Don't print mimalloc warning after mmap() call (gh-113372)Sam Gross2023-12-221-2/+2
| | | | | | | gh-112027: Don't print mimalloc warning after mmap This changes the warning to a "verbose"-level message in prim.c. The address passed to mmap is only a hint -- it's normal for mmap() to sometimes not respect the hint and return a different address.
* gh-113157 gh-89519: Fix method descriptors (gh-113233)Raymond Hettinger2023-12-211-0/+8
| | | Restore behaviors before classmethod descriptor chaining was introduced.
* gh-95754: Better AttributeError on partially initialised module (#112577)Shantanu2023-12-211-2/+22
| | | Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-110383: Improve accuracy of str.split() and str.rsplit() docstrings (#113355)Erlend E. Aasland2023-12-212-5/+9
| | | | Clarify split direction in the docstring body, instead of in the 'maxsplit' param docstring.
* gh-111375: Use `NULL` rather than `None` in the exception stack to indicate ↵Carey Metcalfe2023-12-211-1/+1
| | | | that an exception was handled (#113302)
* gh-111178: Make slot functions in typeobject.c have compatible types (GH-112752)Christopher Chavez2023-12-202-20/+35
|
* gh-112532: Require mimalloc in `--disable-gil` builds (gh-112883)Sam Gross2023-12-121-2/+13
|
* gh-111178: Avoid calling functions from incompatible pointer types in ↵Christopher Chavez2023-12-111-61/+90
| | | | | | | | | | | | | | | | | | | | | | | memoryobject.c (GH-112863) * Make memory_clear() compatible with inquiry * Make memory_traverse() compatible with traverseproc * Make memory_dealloc() compatible with destructor * Make memory_repr() compatible with reprfunc * Make memory_hash() compatible with hashfunc * Make memoryiter_next() compatible with iternextfunc * Make memoryiter_traverse() compatible with traverseproc * Make memoryiter_dealloc() compatible with destructor * Make several functions compatible with getter * Make a few functions compatible with getter * Make memory_item() compatible with ssizeargfunc * Make memory_subscript() compatible with binaryfunc * Make memory_length() compatible with lenfunc * Make memory_ass_sub() compatible with objobjargproc * Make memory_releasebuf() compatible with releasebufferproc * Make memory_getbuf() compatible with getbufferproc * Make mbuf_clear() compatible with inquiry * Make mbuf_traverse() compatible with traverseproc * Make mbuf_dealloc() compatible with destructor
* gh-111924: Use PyMutex for Runtime-global Locks. (gh-112207)Sam Gross2023-12-072-47/+18
| | | | | This replaces some usages of PyThread_type_lock with PyMutex, which does not require memory allocation to initialize. This simplifies some of the runtime initialization and is also one step towards avoiding changing the default raw memory allocator during initialize/finalization, which can be non-thread-safe in some circumstances.
* gh-112125: Fix None.__ne__(None) returning NotImplemented instead of False ↵andrewluotechnologies2023-12-072-1/+7
| | | | (#112504)
* gh-112660: Do not clear arbitrary errors on import (GH-112661)Serhiy Storchaka2023-12-071-32/+25
| | | | | Previously arbitrary errors could be cleared during formatting error messages for ImportError or AttributeError for modules. Now all unexpected errors are reported.
* Minor refactoring of Object/abstract.c (UNARY_FUNC macro and more cases for ↵Sergey B Kirpichev2023-12-051-90/+25
| | | | | | | BINARY_FUNC) (GH-112145) * Use BINARY_FUNC macro for some remaining ops * Add UNARY_FUNC macro to define unary PyNumber_* functions
* gh-112625: Protect bytearray from being freed by misbehaving iterator inside ↵chilaxan2023-12-041-1/+4
| | | | bytearray.join (GH-112626)
* gh-111058: Change coro.cr_frame/gen.gi_frame to be None for a closed ↵Irit Katriel2023-12-011-1/+1
| | | | coroutine/generator. (#112428)
* gh-111972: Make Unicode name C APIcapsule initialization thread-safe (#112249)Kirill Podoprigora2023-11-301-11/+21
|
* gh-76785: Add _PyType_GetModuleName() to the Internal C-API (gh-112323)Eric Snow2023-11-221-0/+6
| | | The new function corresponds to the existing (public) PyType_GetName() and PyType_GetQualName().
* gh-111863: Rename `Py_NOGIL` to `Py_GIL_DISABLED` (#111864)Hugo van Kemenade2023-11-201-3/+3
| | | Rename Py_NOGIL to Py_GIL_DISABLED
* gh-112266: Remove `(if defined)` part from `__dict__` and `__weakref__` ↵Nikita Sobolev2023-11-191-4/+4
| | | | docstrings (#112268)
* gh-112026: Restore removed _PyDict_GetItemStringWithError() (#112119)Victor Stinner2023-11-151-0/+14
| | | | Restore the removed _PyDict_GetItemStringWithError() function. It is used by numpy.
* gh-96954: Fix `make regen-unicodedata` in out-of-tree builds (#112118)Miro Hrončok2023-11-151-1/+1
| | | | | | | | | This avoids: python3.13 Tools/unicode/makeunicodedata.py python3.13: can't open file '.../build/debug/Tools/unicode/makeunicodedata.py': [Errno 2] No such file or directory make: *** [Makefile:1498: regen-unicodedata] Error 2 Re-run `make regen-unicodedata` to update the script path in generated files.
* gh-112026: Restore removed private C API (#112115)Victor Stinner2023-11-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Restore removed private C API functions, macros and structures which have no simple replacement for now: * _PyDict_GetItem_KnownHash() * _PyDict_NewPresized() * _PyHASH_BITS * _PyHASH_IMAG * _PyHASH_INF * _PyHASH_MODULUS * _PyHASH_MULTIPLIER * _PyLong_Copy() * _PyLong_FromDigits() * _PyLong_New() * _PyLong_Sign() * _PyObject_CallMethodId() * _PyObject_CallMethodNoArgs() * _PyObject_CallMethodOneArg() * _PyObject_CallOneArg() * _PyObject_EXTRA_INIT * _PyObject_FastCallDict() * _PyObject_GetAttrId() * _PyObject_Vectorcall() * _PyObject_VectorcallMethod() * _PyStack_AsDict() * _PyThread_CurrentFrames() * _PyUnicodeWriter structure * _PyUnicodeWriter_Dealloc() * _PyUnicodeWriter_Finish() * _PyUnicodeWriter_Init() * _PyUnicodeWriter_Prepare() * _PyUnicodeWriter_PrepareKind() * _PyUnicodeWriter_WriteASCIIString() * _PyUnicodeWriter_WriteChar() * _PyUnicodeWriter_WriteLatin1String() * _PyUnicodeWriter_WriteStr() * _PyUnicodeWriter_WriteSubstring() * _PyUnicode_AsString() * _PyUnicode_FromId() * _PyVectorcall_Function() * _Py_HashDouble() * _Py_HashPointer() * _Py_IDENTIFIER() * _Py_c_abs() * _Py_c_diff() * _Py_c_neg() * _Py_c_pow() * _Py_c_prod() * _Py_c_quot() * _Py_c_sum() * _Py_static_string() * _Py_static_string_init()
* gh-111906: Fix warnings during mimalloc build on FreeBSD (#111907)Furkan Onder2023-11-141-2/+2
| | | Fix `unused function` warnings during mimalloc build on FreeBSD.
* gh-111262: Add PyDict_Pop() function (#112028)Victor Stinner2023-11-143-40/+96
| | | | | | | _PyDict_Pop_KnownHash(): remove the default value and the return type becomes an int. Co-authored-by: Stefan Behnel <stefan_ml@behnel.de> Co-authored-by: Antoine Pitrou <pitrou@free.fr>
* gh-111789: Use PyDict_GetItemRef() in Objects/ (GH-111827)Serhiy Storchaka2023-11-145-120/+76
|
* gh-111138: Add PyList_Extend() and PyList_Clear() functions (#111862)Victor Stinner2023-11-132-122/+177
| | | | | | * Split list_extend() into two sub-functions: list_extend_fast() and list_extend_iter(). * list_inplace_concat() no longer has to call Py_DECREF() on the list_extend() result, since list_extend() now returns an int.
* gh-111999: Add signatures and improve docstrings for builtins (GH-112000)Serhiy Storchaka2023-11-136-27/+53
|
* gh-110481: fix 'unused function' warning for `is_shared_refcnt_dead`. ↵Sam Gross2023-11-101-4/+6
| | | | | | | (gh-111974) Fix 'unused function' warning for `is_shared_refcnt_dead`. The `is_shared_refcnt_dead` function is only used if `Py_REF_DEBUG` is set.
* Add private _PyUnicode_AsUTF8NoNUL() function (GH-111957)Serhiy Storchaka2023-11-101-0/+12
| | | | Like PyUnicode_AsUTF8(), but check for embedded null characters.
* Improve error message for "float modulo by zero" (#111685)Pavel Ovchinnikov2023-11-091-1/+1
|
* gh-111354: remove comparisons with enum values, variable reuse, unused ↵Irit Katriel2023-11-091-22/+14
| | | | imports in genobject.c (#111708)
* gh-111569: Implement Python critical section API (gh-111571)Sam Gross2023-11-081-1/+1
| | | | | | | | Critical sections are helpers to replace the global interpreter lock with finer grained locking. They provide similar guarantees to the GIL and avoid the deadlock risk that plain locking involves. Critical sections are implicitly ended whenever the GIL would be released. They are resumed when the GIL would be acquired. Nested critical sections behave as if the sections were interleaved.
* gh-110543: Fix CodeType.replace in presence of comprehensions (#110586)Jelle Zijlstra2023-11-081-0/+29
|
* gh-111089: Revert PyUnicode_AsUTF8() changes (#111833)Victor Stinner2023-11-077-29/+92
| | | | | | | | | | | | | | | | | | | | | * Revert "gh-111089: Use PyUnicode_AsUTF8() in Argument Clinic (#111585)" This reverts commit d9b606b3d04fc56fb0bcc479d7d6c14562edb5e2. * Revert "gh-111089: Use PyUnicode_AsUTF8() in getargs.c (#111620)" This reverts commit cde1071b2a72e8261ca66053ef61431b7f3a81fd. * Revert "gh-111089: PyUnicode_AsUTF8() now raises on embedded NUL (#111091)" This reverts commit d731579bfb9a497cfb0076cb6b221058a20088fe. * Revert "gh-111089: Add PyUnicode_AsUTF8() to the limited C API (#111121)" This reverts commit d8f32be5b6a736dc2fc9dca3f1bf176c82fc9b44. * Revert "gh-111089: Use PyUnicode_AsUTF8() in sqlite3 (#111122)" This reverts commit 37e4e20eaa8f27ada926d49e5971fecf0477ad26.
* gh-81137: deprecate assignment of code object to a function of a mismatched ↵Irit Katriel2023-11-071-0/+14
| | | | type (#111823)
* gh-106672: C API: Report indiscriminately ignored errors (GH-106674)Serhiy Storchaka2023-11-073-25/+69
| | | | | Functions which indiscriminately ignore all errors now report them as unraisable errors.
* gh-79932: raise exception if frame.clear() is called on a suspended frame ↵Irit Katriel2023-11-071-0/+7
| | | | (#111792)
* simplify code to pop exception in frame_setlineno (#111702)Irit Katriel2023-11-061-5/+2
|
* gh-111666: Speed up `BaseExceptionGroup.{derive,split,subgroup}` (#111667)Nikita Sobolev2023-11-041-20/+6
|
* gh-111506: Implement Py_SET_REFCNT() as opaque function in limited C API ↵Victor Stinner2023-11-031-0/+8
| | | | | | | | (#111508) In the limited C API version 3.13, Py_SET_REFCNT() function is now implemented as an opaque function call. Add _Py_SetRefcnt() to the stable ABI.
* gh-103615: Use local events for opcode tracing (GH-109472)Tian Gao2023-11-031-1/+7
| | | | | | | * Use local monitoring for opcode trace * Remove f_opcode_trace_set * Add test for setting f_trace_opcodes after settrace