summaryrefslogtreecommitdiffstats
path: root/Include/object.h
Commit message (Collapse)AuthorAgeFilesLines
* gh-120198: Stop the world when setting __class__ on free-threaded build ↵Ken Jin2024-07-101-8/+0
| | | | (GH-120672)
* gh-117511: Make PyMutex public in the non-limited API (#117731)Sam Gross2024-06-201-5/+1
|
* GH-119462: Enforce invariants of type versioning (GH-120731)Mark Shannon2024-06-191-1/+1
| | | | * Remove uses of Py_TPFLAGS_VALID_VERSION_TAG
* gh-120600: Make Py_TYPE() opaque in limited C API 3.14 (#120601)Victor Stinner2024-06-181-9/+19
| | | | In the limited C API 3.14 and newer, Py_TYPE() is now implemented as an opaque function call to hide implementation details.
* gh-83754: Use the Py_TYPE() macro (#120599)Victor Stinner2024-06-171-4/+4
| | | | Don't access directly PyObject.ob_type, but use the Py_TYPE() macro instead.
* gh-117657: Make PyType_HasFeature (exported version) atomic (#120484)Ken Jin2024-06-151-1/+5
| | | Make PyType_HasFeature (exported version) atomic
* gh-117657: Make Py_TYPE and Py_SET_TYPE thread safe (GH-120165)Ken Jin2024-06-121-0/+8
| | | | Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Nadeshiko Manju <me@manjusaka.me>
* gh-119853: Add Include/refcount.h file (#119854)Victor Stinner2024-05-311-482/+0
|
* gh-117657: Fix race data race in `_Py_IsOwnedByCurrentThread()` (#118258)mpage2024-04-261-0/+4
|
* gh-117657: Fix data race in `_Py_IsImmortal` (#118261)mpage2024-04-251-1/+2
| | | | The load of `ob_ref_local races with stores. Using a relaxed load is sufficient; stores to the field are relaxed.
* GH-115776: Static object are immortal, so mark them as such. (GH-117673)Mark Shannon2024-04-161-10/+7
|
* GH-115776: Embed the values array into the object, for "normal" Python ↵Mark Shannon2024-04-021-1/+6
| | | | objects. (GH-116115)
* gh-116936: Add PyType_GetModuleByDef() to the limited C API (#116937)Victor Stinner2024-03-251-0/+4
|
* gh-115754: Add Py_GetConstant() function (#116883)Victor Stinner2024-03-211-2/+29
| | | | | | | | | | | | Add Py_GetConstant() and Py_GetConstantBorrowed() functions. In the limited C API version 3.13, getting Py_None, Py_False, Py_True, Py_Ellipsis and Py_NotImplemented singletons is now implemented as function calls at the stable ABI level to hide implementation details. Getting these constants still return borrowed references. Add _testlimitedcapi/object.c and test_capi/test_object.py to test Py_GetConstant() and Py_GetConstantBorrowed() functions.
* gh-116869: Make C API compatible with ISO C90 (#116950)Victor Stinner2024-03-181-2/+1
| | | | Make the C API compatible with -Werror=declaration-after-statement compiler flag again.
* gh-111696, PEP 737: Add PyType_GetModuleName() function (#116824)Victor Stinner2024-03-141-1/+2
| | | Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* gh-111696, PEP 737: Add PyType_GetFullyQualifiedName() function (#116815)Victor Stinner2024-03-141-0/+3
| | | Rewrite tests on type names in Python, they were written in C.
* gh-112529: Remove PyGC_Head from object pre-header in free-threaded build ↵Sam Gross2024-02-011-2/+3
| | | | | | | | | | | | | | | | | (#114564) * gh-112529: Remove PyGC_Head from object pre-header in free-threaded build This avoids allocating space for PyGC_Head in the free-threaded build. The GC implementation for free-threaded CPython does not use the PyGC_Head structure. * The trashcan mechanism uses the `ob_tid` field instead of `_gc_prev` in the free-threaded build. * The GDB libpython.py file now determines the offset of the managed dict field based on whether the running process is a free-threaded build. Those are identified by the `ob_ref_local` field in PyObject. * Fixes `_PySys_GetSizeOf()` which incorrectly incorrectly included the size of `PyGC_Head` in the size of static `PyTypeObject`.
* gh-112087: Make PyList_{Append,Size,GetSlice} to be thread-safe (gh-114651)Donghee Na2024-01-311-0/+4
|
* gh-112529: Implement GC for free-threaded builds (#114262)Sam Gross2024-01-251-1/+3
| | | | | | | * gh-112529: Implement GC for free-threaded builds This implements a mark and sweep GC for the free-threaded builds of CPython. The implementation relies on mimalloc to find GC tracked objects (i.e., "containers").
* gh-112535: Implement fallback implementation of _Py_ThreadId() (gh-113185)Donghee Na2023-12-181-1/+5
| | | | | --------- Co-authored-by: Sam Gross <colesbury@gmail.com>
* gh-112535: Update _Py_ThreadId() to support RISC-V (gh-113084)Furkan Onder2023-12-141-0/+7
| | | Update _Py_ThreadId() to support RISC-V
* gh-112535: Update _Py_ThreadId() to support s390/s390x (gh-112751)Donghee Na2023-12-081-0/+4
|
* gh-112535: Add comment for ppc32/64 registers (gh-112746)Donghee Na2023-12-051-0/+2
|
* gh-112535: Update _Py_ThreadId() to support PowerPC (gh-112624)Donghee Na2023-12-051-0/+16
|
* gh-110481: Fix typo in Py_SET_REFCNT() (#112595)Victor Stinner2023-12-011-3/+3
|
* gh-110481: Fix Py_SET_REFCNT() integer overflow (#112174)Victor Stinner2023-12-011-10/+21
| | | | | | | | | | | | | | If Py_NOGIL is defined and Py_SET_REFCNT() is called with a reference count larger than UINT32_MAX, make the object immortal. Set _Py_IMMORTAL_REFCNT constant type to Py_ssize_t to fix the following compiler warning: Include/internal/pycore_global_objects_fini_generated.h:14:24: warning: comparison of integers of different signs: 'Py_ssize_t' (aka 'long') and 'unsigned int' [-Wsign-compare] if (Py_REFCNT(obj) < _Py_IMMORTAL_REFCNT) { ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~
* gh-111863: Rename `Py_NOGIL` to `Py_GIL_DISABLED` (#111864)Hugo van Kemenade2023-11-201-13/+13
| | | Rename Py_NOGIL to Py_GIL_DISABLED
* gh-112026: Restore removed private C API (#112115)Victor Stinner2023-11-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-111569: Implement Python critical section API (gh-111571)Sam Gross2023-11-081-2/+6
| | | | | | | | 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-111506: Implement Py_SET_REFCNT() as opaque function in limited C API ↵Victor Stinner2023-11-031-2/+11
| | | | | | | | (#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-110481: Fix _Py_ThreadId for non-free-threaded mode (gh-111503)Donghee Na2023-10-301-3/+1
|
* gh-110481: Implement biased reference counting (gh-110764)Sam Gross2023-10-301-3/+188
|
* gh-109496: Detect Py_DECREF() after dealloc in debug mode (#109539)Victor Stinner2023-09-181-6/+4
| | | | | | | | | On a Python built in debug mode, Py_DECREF() now calls _Py_NegativeRefcount() if the object is a dangling pointer to deallocated memory: memory filled with 0xDD "dead byte" by the debug hook on memory allocators. The fix is to check the reference count *before* checking for _Py_IsImmortal(). Add test_decref_freed_object() to test_capi.test_misc.
* gh-108511: Add C API functions which do not silently ignore errors (GH-109025)Serhiy Storchaka2023-09-171-0/+4
| | | | | | | | | Add the following functions: * PyObject_HasAttrWithError() * PyObject_HasAttrStringWithError() * PyMapping_HasKeyWithError() * PyMapping_HasKeyStringWithError()
* gh-108765: Move standard includes to Python.h (#108769)Victor Stinner2023-09-011-2/+0
| | | | | | | | | | | | * Move <ctype.h>, <limits.h> and <stdarg.h> standard includes to Python.h. * Move "pystats.h" include from object.h to Python.h. * Remove redundant "pymem.h" include in objimpl.h and "pyport.h" include in pymem.h; Python.h already includes them earlier. * Remove redundant <wchar.h> include in unicodeobject.h; Python.h already includes it. * Move _SGI_MP_SOURCE define from Python.h to pyport.h. * pycore_condvar.h includes explicitly <unistd.h> for the _POSIX_THREADS macro.
* gh-108634: Py_TRACE_REFS uses a hash table (#108663)Victor Stinner2023-08-311-21/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Python built with "configure --with-trace-refs" (tracing references) is now ABI compatible with Python release build and debug build. Moreover, it now also supports the Limited API. Change Py_TRACE_REFS build: * Remove _PyObject_EXTRA_INIT macro. * The PyObject structure no longer has two extra members (_ob_prev and _ob_next). * Use a hash table (_Py_hashtable_t) to trace references (all objects): PyInterpreterState.object_state.refchain. * Py_TRACE_REFS build is now ABI compatible with release build and debug build. * Limited C API extensions can now be built with Py_TRACE_REFS: xxlimited, xxlimited_35, _testclinic_limited. * No longer rename PyModule_Create2() and PyModule_FromDefAndSpec2() functions to PyModule_Create2TraceRefs() and PyModule_FromDefAndSpec2TraceRefs(). * _Py_PrintReferenceAddresses() is now called before finalize_interp_delete() which deletes the refchain hash table. * test_tracemalloc find_trace() now also filters by size to ignore the memory allocated by _PyRefchain_Trace(). Test changes for Py_TRACE_REFS: * Add test.support.Py_TRACE_REFS constant. * Add test_sys.test_getobjects() to test sys.getobjects() function. * test_exceptions skips test_recursion_normalizing_with_no_memory() and test_memory_error_in_PyErr_PrintEx() if Python is built with Py_TRACE_REFS. * test_repl skips test_no_memory(). * test_capi skisp test_set_nomemory().
* gh-106320: Remove private _PyObject_GetState() (#108606)Victor Stinner2023-08-291-6/+0
| | | | Move the private _PyObject_GetState() function to the internal C API (pycore_object.h).
* gh-107955 Remove old comment about increasing the reference count in usage ↵brandonardenwalli2023-08-161-2/+0
| | | | of Py_None (#107993)
* gh-105059: Fix MSCV compiler warning on PyObject union (#107239)Victor Stinner2023-07-251-0/+11
| | | | Use pragma to ignore the MSCV compiler warning on the PyObject nameless union.
* gh-105059: Use GCC/clang extension for PyObject union (#107232)Victor Stinner2023-07-251-0/+5
| | | | | Anonymous union is new in C11. To prevent compiler warning when using -pedantic compiler option, use Clang and GCC extension on C99 and older.
* gh-102304: Rename _Py_IncRefTotal_DO_NOT_USE_THIS() (#107193)Victor Stinner2023-07-241-9/+4
| | | | | * Rename _Py_IncRefTotal_DO_NOT_USE_THIS() to _Py_INCREF_IncRefTotal() * Rename _Py_DecRefTotal_DO_NOT_USE_THIS() to _Py_DECREF_DecRefTotal() * Remove temporary _Py_INC_REFTOTAL() and _Py_DEC_REFTOTAL() macros
* gh-106521: Add PyObject_GetOptionalAttr() function (GH-106522)Serhiy Storchaka2023-07-111-0/+4
| | | | | | It is a new name of former _PyObject_LookupAttr(). Add also PyObject_GetOptionalAttrString().
* gh-106572: Convert PyObject_DelAttr() to a function (#106611)Victor Stinner2023-07-111-0/+2
| | | | | | | | * Convert PyObject_DelAttr() and PyObject_DelAttrString() macros to functions. * Add PyObject_DelAttr() and PyObject_DelAttrString() functions to the stable ABI. * Replace PyObject_SetAttr(obj, name, NULL) with PyObject_DelAttr(obj, name).
* gh-105387: Limited C API implements Py_INCREF() as func (#105388)Victor Stinner2023-06-141-8/+10
| | | | | In the limited C API version 3.12, Py_INCREF() and Py_DECREF() functions are now implemented as opaque function calls to hide implementation details.
* gh-102304: Fix Py_INCREF() for limited C API 3.9 (#105550)Victor Stinner2023-06-091-2/+14
| | | | | | When Python is built in debug mode (Py_REF_DEBUG macro), Py_INCREF() and Py_DECREF() of the limited C API 3.9 (and older) now call Py_IncRef() and Py_DecRef(), since _Py_IncRef() and _Py_DecRef() were added to Python 3.10.
* gh-102304: Fix Py_INCREF() stable ABI in debug mode (#104763)Victor Stinner2023-06-061-14/+8
| | | | | | | | | | | When Python is built in debug mode (if the Py_REF_DEBUG macro is defined), the Py_INCREF() and Py_DECREF() function are now always implemented as opaque functions to avoid leaking implementation details like the "_Py_RefTotal" variable or the _Py_DecRefTotal_DO_NOT_USE_THIS() function. * Remove _Py_IncRefTotal_DO_NOT_USE_THIS() and _Py_DecRefTotal_DO_NOT_USE_THIS() from the stable ABI. * Remove _Py_NegativeRefcount() from limited C API.
* gh-102304: Fix 2 New Stable ABI Functions (gh-104762)Eric Snow2023-05-301-1/+1
|
* gh-102304: Temporarily Bump Py_LIMITED_API for 2 New Functions (#104766)Eric Snow2023-05-221-1/+1
| | | Quick and dirty.
* gh-103509: PEP 697 -- Limited C API for Extending Opaque Types (GH-103511)Petr Viktorin2023-05-041-0/+5
| | | | Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>