summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-130382: add missing `_PyReftracerTrack` to ceval `Py_DECREF` ↵Sam Gross2025-03-141-0/+26
| | | | | | | (GH-130689) (#131195) (cherry picked from commit c5abded09995f208b21ebaf012185ca5acb0180b) Co-authored-by: Tomasz Pytel <tompytel@gmail.com>
* [3.13] gh-129185: Fix PyTraceMalloc_Untrack() at Python exit (#129191) (#129217)Victor Stinner2025-01-231-0/+1
| | | | | | | | | | | | | gh-129185: Fix PyTraceMalloc_Untrack() at Python exit (#129191) Support calling PyTraceMalloc_Track() and PyTraceMalloc_Untrack() during late Python finalization. * Call _PyTraceMalloc_Fini() later in Python finalization. * Test also PyTraceMalloc_Untrack() without the GIL * PyTraceMalloc_Untrack() now gets the GIL. * Test also PyTraceMalloc_Untrack() in test_tracemalloc_track_race(). (cherry picked from commit 46c7e13c055c218e18b0424efc60965e6a5fe6ea)
* [3.13] gh-128679: Fix tracemalloc.stop() race conditions (#128897)Victor Stinner2025-01-181-0/+99
| | | | | | | | | | | | | tracemalloc_alloc(), tracemalloc_realloc(), PyTraceMalloc_Track(), PyTraceMalloc_Untrack() and _PyTraceMalloc_TraceRef() now check tracemalloc_config.tracing after calling TABLES_LOCK(). _PyTraceMalloc_Stop() now protects more code with TABLES_LOCK(), especially setting tracemalloc_config.tracing to 1. Add a test using PyTraceMalloc_Track() to test tracemalloc.stop() race condition. Call _PyTraceMalloc_Init() at Python startup.
* [3.13] gh-111495: Add more tests on PyEval C APIs (#122789) (#128987)Victor Stinner2025-01-181-21/+0
| | | | | | | | | | | | * gh-111495: Add more tests on PyEval C APIs (#122789) * Add Lib/test/test_capi/test_eval.py * Add Modules/_testlimitedcapi/eval.c (cherry picked from commit bf8b3746398ea756c97e3cf263d63ca3ce3a544e) * gh-111495: Fix refleaks in test_capi.test_eval tests (#122851) (cherry picked from commit b4a316087c32d83e375087fd35fc511bc430ee8b)
* [3.13] gh-128911: Add tests on the PyImport C API (#128915) (#128960)Victor Stinner2025-01-171-47/+0
| | | | | | | | | | | gh-128911: Add tests on the PyImport C API (#128915) * Add Modules/_testlimitedcapi/import.c * Add Lib/test/test_capi/test_import.py * Remove _testcapi.check_pyimport_addmodule(): tests already covered by newly added tests. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit d95ba9fa1110534b7247fa2ff12b90e930c93256)
* [3.13] gh-127791: Fix, document, and test `PyUnstable_AtExit` (GH-127793) ↵Peter Bierma2024-12-111-0/+49
| | | | | | | | | | (#127819) * Fix merge conflicts. * [3.13] gh-127791: Fix, document, and test `PyUnstable_AtExit` (GH-127793) (cherry picked from commit d5d84c3f13fe7fe591b375c41979d362bc11957a) Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* [3.13] gh-122728: Fix SystemError in PyEval_GetLocals() (GH-122735) (#122757)Miss Islington (bot)2024-08-061-0/+7
| | | | | | | | | | | | gh-122728: Fix SystemError in PyEval_GetLocals() (GH-122735) Fix PyEval_GetLocals() to avoid SystemError ("bad argument to internal function"). Don't redefine the 'ret' variable in the if block. Add an unit test on PyEval_GetLocals(). (cherry picked from commit 4767a6e31c0550836b2af45d27e374e721f0c4e6) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-119344: Make critical section API public (GH-119353) (#120856)Sam Gross2024-06-211-0/+13
| | | | | | | | | | | This makes the following macros public as part of the non-limited C-API for locking a single object or two objects at once. * `Py_BEGIN_CRITICAL_SECTION(op)` / `Py_END_CRITICAL_SECTION()` * `Py_BEGIN_CRITICAL_SECTION2(a, b)` / `Py_END_CRITICAL_SECTION2()` The supporting functions and structs used by the macros are also exposed for cases where C macros are not available. (cherry picked from commit 8f17d69b7bc906e8407095317842cc0fd52cd84a)
* [3.13] GH-119462: Enforce invariants of type versioning. Backport of ↵Mark Shannon2024-06-201-1/+1
| | | | | GH-120731. (#120748) * Remove uses of Py_TPFLAGS_VALID_VERSION_TAG
* [3.13] gh-119585: Fix crash involving `PyGILState_Release()` and ↵Miss Islington (bot)2024-05-311-0/+9
| | | | | | | | | | | | | `PyThreadState_Clear()` (GH-119753) (#119859) Make sure that `gilstate_counter` is not zero in when calling `PyThreadState_Clear()`. A destructor called from `PyThreadState_Clear()` may call back into `PyGILState_Ensure()` and `PyGILState_Release()`. If `gilstate_counter` is zero, it will try to create a new thread state before the current active thread state is destroyed, leading to an assertion failure or crash. (cherry picked from commit bcc1be39cb1d04ad9fc0bd1b9193d3972835a57c) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-119049: Fix incorrect display of warning which is constructed by C ↵Miss Islington (bot)2024-05-171-0/+10
| | | | | | | | | API (GH-119063) (GH-119106) The source line was not displayed if the warnings module had not yet been imported. (cherry picked from commit 100c7ab00ab66a8c0d54582f35e38d8eb691743c) Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
* gh-116322: Rename PyModule_ExperimentalSetGIL to PyUnstable_Module_SetGIL ↵Petr Viktorin2024-05-061-1/+1
| | | | (GH-118645)
* gh-111997: C-API for signalling monitoring events (#116413)Irit Katriel2024-05-041-0/+3
|
* gh-116322: Add Py_mod_gil module slot (#116882)Brett Simmers2024-05-031-0/+3
| | | | | | | | | | | | | | This PR adds the ability to enable the GIL if it was disabled at interpreter startup, and modifies the multi-phase module initialization path to enable the GIL when loading a module, unless that module's spec includes a slot indicating it can run safely without the GIL. PEP 703 called the constant for the slot `Py_mod_gil_not_used`; I went with `Py_MOD_GIL_NOT_USED` for consistency with gh-104148. A warning will be issued up to once per interpreter for the first GIL-using module that is loaded. If `-v` is given, a shorter message will be printed to stderr every time a GIL-using module is loaded (including the first one that issues a warning).
* gh-93502: Add new C-API functions to trace object creation and destruction ↵Pablo Galindo Salgado2024-05-021-0/+84
| | | | (#115945)
* gh-118379: Use PyTuple_Pack instead of Py_BuildValue if possible (GH-118381)Nice Zombies2024-04-301-2/+2
|
* gh-110693: Pending Calls Machinery Cleanups (gh-118296)Eric Snow2024-04-261-11/+42
| | | This does some cleanup in preparation for later changes.
* gh-117968: Add tests for the part of the PyRun family of the C API (GH-117982)Serhiy Storchaka2024-04-171-0/+13
| | | | Co-authored-by: NGRsoftlab <78017794+NGRsoftlab@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-117694: Improve tests for PyEval_EvalCodeEx() (GH-117695)Serhiy Storchaka2024-04-151-80/+33
|
* GH-115776: Embed the values array into the object, for "normal" Python ↵Mark Shannon2024-04-021-1/+3
| | | | objects. (GH-116115)
* gh-94808:Improve coverage of PyObject_Print (GH-98749)MonadChains2024-04-011-0/+3
|
* gh-87193: Support bytes objects with refcount > 1 in _PyBytes_Resize() ↵Serhiy Storchaka2024-03-251-0/+3
| | | | | (GH-117160) Create a new bytes object and destroy the old one if it has refcount > 1.
* gh-76785: Drop PyInterpreterID_Type (gh-117101)Eric Snow2024-03-211-8/+0
| | | I added it quite a while ago as a strategy for managing interpreter lifetimes relative to the PEP 554 (now 734) implementation. Relatively recently I refactored that implementation to no longer rely on InterpreterID objects. Thus now I'm removing it.
* gh-76785: Clean Up Interpreter ID Conversions (gh-117048)Eric Snow2024-03-211-26/+0
| | | Mostly we unify the two different implementations of the conversion code (from PyObject * to int64_t. We also drop the PyArg_ParseTuple()-style converter function, as well as rename and move PyInterpreterID_LookUp().
* gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit ↵Serhiy Storchaka2024-03-201-0/+1
| | | | platforms (GH-117064)
* gh-94808: add tests covering `PyFunction_{Get,Set}Closure` (GH-99429)Nikita Sobolev2024-03-201-0/+29
|
* gh-111696, PEP 737: Add PyType_GetModuleName() function (#116824)Victor Stinner2024-03-141-0/+9
| | | Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* gh-111696, PEP 737: Add PyType_GetFullyQualifiedName() function (#116815)Victor Stinner2024-03-141-68/+17
| | | Rewrite tests on type names in Python, they were written in C.
* gh-116417: Move 4 limited C API test files to _testlimitedcapi (#116571)Victor Stinner2024-03-111-12/+0
| | | | | | | | | | | | | | | | Move the following files from Modules/_testcapi/ to Modules/_testlimitedcapi/: * bytearray.c * bytes.c * pyos.c * sys.c Changes: * Replace PyBytes_AS_STRING() with PyBytes_AsString(). * Replace PyBytes_GET_SIZE() with PyBytes_Size(). * Update related test_capi tests. * Copy Modules/_testcapi/util.h to Modules/_testlimitedcapi/util.h.
* gh-116417: Add _testlimitedcapi C extension (#116419)Victor Stinner2024-03-071-6/+0
| | | | | | | | | | | | | Add a new C extension "_testlimitedcapi" which is only built with the limited C API. Move heaptype_relative.c and vectorcall_limited.c from Modules/_testcapi/ to Modules/_testlimitedcapi/. * configure: add _testlimitedcapi test extension. * Update generate_stdlib_module_names.py. * Update make check-c-globals. Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-110850: Add PyTime_t C API (GH-115215)Petr Viktorin2024-02-121-0/+3
| | | | | | | | | | | | * gh-110850: Add PyTime_t C API Add PyTime_t API: * PyTime_t type. * PyTime_MIN and PyTime_MAX constants. * PyTime_AsSecondsDouble(), PyTime_Monotonic(), PyTime_PerfCounter() and PyTime_GetSystemClock() functions. Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-114685: PyBuffer_FillInfo() now raises on PyBUF_{READ,WRITE} (GH-114802)Nikita Sobolev2024-02-041-0/+21
|
* gh-114101: Correct PyErr_Format arguments in _testcapi module (#114102)AN Long2024-01-161-6/+6
| | | | - use PyErr_SetString() iso. PyErr_Format() in parse_tuple_and_keywords() - fix misspelled format specifier in CHECK_SIGNNESS() macro
* gh-89811: Check for valid tp_version_tag in specializer (GH-113558)Peter Lazorchak2024-01-111-0/+29
|
* gh-113787: Fix refleaks in test_capi (gh-113816)neonene2024-01-081-2/+1
| | | Fix refleaks and a typo.
* GH-113633: Use module state structure for _testcapi. (GH-113634)Neil Schemenauer2024-01-011-51/+64
| | | Use module state structure for _testcapi.
* bpo-36796: Clean the error handling in _testcapimodule.c (GH-13085)Zackery Spytz2023-12-141-6/+12
|
* gh-76785: Fixes for test.support.interpreters (gh-112982)Eric Snow2023-12-121-0/+34
| | | This involves a number of changes for PEP 734.
* gh-76785: Add _PyType_GetModuleName() to the Internal C-API (gh-112323)Eric Snow2023-11-221-0/+7
| | | The new function corresponds to the existing (public) PyType_GetName() and PyType_GetQualName().
* gh-111545: Test PyHash_GetFuncDef() function (#112098)Victor Stinner2023-11-151-0/+3
| | | Add Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
* gh-111495: add stub files for C API test modules (GH-111586)Sergey B Kirpichev2023-11-011-0/+24
| | | | | This is to reduce merge conflicts (Modules/Setup.stdlib.in) for subsequent pull requests for the issue.
* gh-76785: Move the Cross-Interpreter Code to Its Own File (gh-111502)Eric Snow2023-10-301-54/+0
| | | This is partly to clear this stuff out of pystate.c, but also in preparation for moving some code out of _xxsubinterpretersmodule.c. This change also moves this stuff to the internal API (new: Include/internal/pycore_crossinterp.h). @vstinner did this previously and I undid it. Now I'm re-doing it. :/
* gh-111065: Add more tests for the C API with the PySys_ prefix (GH-111067)Serhiy Storchaka2023-10-251-31/+3
| | | | | | | * Move existing tests for PySys_GetObject() and PySys_SetObject() into specialized files. * Add test for PySys_GetXOptions() using _testcapi. * Add tests for PySys_FormatStdout(), PySys_FormatStderr(), PySys_WriteStdout() and PySys_WriteStderr() using ctypes.
* gh-110964: Remove private _PyArg functions (#110966)Victor Stinner2023-10-171-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the following private functions and structures to pycore_modsupport.h internal C API: * _PyArg_BadArgument() * _PyArg_CheckPositional() * _PyArg_NoKeywords() * _PyArg_NoPositional() * _PyArg_ParseStack() * _PyArg_ParseStackAndKeywords() * _PyArg_Parser structure * _PyArg_UnpackKeywords() * _PyArg_UnpackKeywordsWithVararg() * _PyArg_UnpackStack() * _Py_ANY_VARARGS() Changes: * Python/getargs.h now includes pycore_modsupport.h to export functions. * clinic.py now adds pycore_modsupport.h when one of these functions is used. * Add pycore_modsupport.h includes when a C extension uses one of these functions. * Define Py_BUILD_CORE_MODULE in C extensions which now include directly or indirectly (via code generated by Argument Clinic) pycore_modsupport.h: * _csv * _curses_panel * _dbm * _gdbm * _multiprocessing.posixshmem * _sqlite.row * _statistics * grp * resource * syslog * _testcapi: bad_get() no longer uses METH_FASTCALL calling convention but METH_VARARGS. Replace _PyArg_UnpackStack() with PyArg_ParseTuple(). * _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined by _testcapi sub-modules which need the internal C API (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c, watchers.c. * Remove Include/cpython/modsupport.h header file. Include/modsupport.h no longer includes the removed header file. * Fix mypy clinic.py
* gh-110628: Add tests for PyLong C API (GH-110629)Serhiy Storchaka2023-10-141-0/+2
|
* gh-84489: C API: Add tests for Py_BuildValue() (GH-110596)Serhiy Storchaka2023-10-111-0/+37
|
* gh-110525: Add CAPI tests for set and frozenset objects (GH-110526)Nikita Sobolev2023-10-091-0/+3
|
* gh-108867: Add PyThreadState_GetUnchecked() function (#108870)Victor Stinner2023-10-031-2/+2
| | | | | | Add PyThreadState_GetUnchecked() function: similar to PyThreadState_Get(), but don't issue a fatal error if it is NULL. The caller is responsible to check if the result is NULL. Previously, this function was private and known as _PyThreadState_UncheckedGet().
* gh-107073: Make PyObject_VisitManagedDict() public (#108763)Victor Stinner2023-10-021-1/+1
| | | | | | | | Make PyObject_VisitManagedDict() and PyObject_ClearManagedDict() functions public in Python 3.13 C API. * Rename _PyObject_VisitManagedDict() to PyObject_VisitManagedDict(). * Rename _PyObject_ClearManagedDict() to PyObject_ClearManagedDict(). * Document these functions.
* gh-109723: Disable Py_BUILD_CORE in _testcapi (#109727)Victor Stinner2023-09-221-19/+6
| | | | | | | | | | | | | | | | | | Make sure that the internal C API is not tested by mistake by _testcapi. Undefine Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE macros in Modules/_testcapi/parts.h: move code from _testcapimodule.c. heaptype_relative.c and vectorcall_limited.c are using the limited C API which is incompatible with the internal C API. Move test_long_numbits() from _testcapi to _testinternalcapi since it uses the internal C API "pycore_long.h". Fix Modules/_testcapi/pyatomic.c: don't include Python.h directly, just include _testcapi/parts.h. Ajust "make check-c-globals" for these changes.