summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapi
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-136288: Fix error message in `_testcapi/vectorcall.c` (GH-136258) ↵Miss Islington (bot)2025-07-041-4/+4
| | | | | | | | | | (GH-136295) gh-136288: Fix error message in `_testcapi/vectorcall.c` (GH-136258) Use the %N format specifier instead of %s and `PyType_GetName`. (cherry picked from commit d1d5dce14f90d777608e4403d09079421ff55944) Co-authored-by: William S Fulton <wsf@fultondesigns.co.uk>
* [3.13] gh-111495: Add PyFile tests (#129449) (#129477)Victor Stinner2025-01-302-5/+56
| | | | | | | | | | | | | | | | | | gh-111495: Add PyFile tests (#129449) Add tests for the following functions in test_capi.test_file: * PyFile_FromFd() * PyFile_GetLine() * PyFile_NewStdPrinter() * PyFile_WriteObject() * PyFile_WriteString() * PyObject_AsFileDescriptor() Add Modules/_testlimitedcapi/file.c file. Remove test_embed.StdPrinterTests which became redundant. (cherry picked from commit 4ca9fc08f89bf7172d41e523d9e520eb1729ee8c)
* [3.13] gh-129185: Fix PyTraceMalloc_Untrack() at Python exit (#129191) (#129217)Victor Stinner2025-01-231-2/+11
| | | | | | | | | | | | | 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-126742: Add _PyErr_SetLocaleString, use it for gdbm & dlerror ↵Miss Islington (bot)2024-12-171-0/+1
| | | | | | | | | | messages (GH-126746) (GH-128023) - Add a helper to set an error from locale-encoded `char*` - Use the helper for gdbm & dlerror messages (cherry picked from commit 7303f06846b69016a075bca7ad7c6055f29ad024) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-111495: Add tests for PyNumber C API (GH-111996) (#123375)Miss Islington (bot)2024-09-021-0/+161
| | | | | | gh-111495: Add tests for PyNumber C API (GH-111996) (cherry picked from commit 2f20f5a9bc7dafdb3c2ae723da90eca1727a95f7) Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
* [3.13] gh-111495: Add tests for PyTuple C API (GH-118757) (GH-123371)Sergey B Kirpichev2024-08-271-1/+108
| | | | | | | (cherry picked from commit dbc1752d4107532d312c78263212e807a3674eb1) Co-authored-by: kalyanr <kalyan.ben10@live.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-121791: Check for `NULL` in `MethodDescriptor2_new` in `_testcapi` ↵Miss Islington (bot)2024-07-161-0/+3
| | | | | | | | (GH-121792) (#121839) gh-121791: Check for `NULL` in `MethodDescriptor2_new` in `_testcapi` (GH-121792) (cherry picked from commit 8b6d4755812d0b02e9f26beb9c9a7714e4c5ac28) Co-authored-by: sobolevn <mail@sobolevn.me>
* [3.13] gh-121368: Fix seq lock memory ordering in _PyType_Lookup (GH-121388) ↵Miss Islington (bot)2024-07-081-0/+1
| | | | | | | | | | | | | | (#121505) The `_PySeqLock_EndRead` function needs an acquire fence to ensure that the load of the sequence happens after any loads within the read side critical section. The missing fence can trigger bugs on macOS arm64. Additionally, we need a release fence in `_PySeqLock_LockWrite` to ensure that the sequence update is visible before any modifications to the cache entry. (cherry picked from commit 1d3cf79a501a93a7a488fc75d4db3060c5ee7d1a) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-118789: Add `PyUnstable_Object_ClearWeakRefsNoCallbacks` ↵Miss Islington (bot)2024-06-181-0/+8
| | | | | | | | | | | | | | | | | (GH-118807) (#120695) This exposes `PyUnstable_Object_ClearWeakRefsNoCallbacks` as an unstable C-API function to provide a thread-safe mechanism for clearing weakrefs without executing callbacks. Some C-API extensions need to clear weakrefs without calling callbacks, such as after running finalizers like we do in subtype_dealloc. Previously they could use `_PyWeakref_ClearRef` on each weakref, but that's not thread-safe in the free-threaded build. (cherry picked from commit e8752d7b80775ec2a348cd4bf38cbe26a4a07615) Co-authored-by: Sam Gross <colesbury@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* [3.13] gh-117398: Add datetime C-API type check test for subinterpreters ↵Miss Islington (bot)2024-06-131-3/+45
| | | | | | | | | (gh-120463) Check if the DateTime C-API type matches the datetime.date type on main and shared/isolated subinterpreters. (cherry picked from commit 50a389565aa0b480792ed06a2ab56fb5a72fc2d8, AKA gh-119604) Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
* [3.13] gh-118692: Avoid creating unnecessary StopIteration instances for ↵Miss Islington (bot)2024-05-241-4/+5
| | | | | | | | | | monitoring (GH-119216) (#119497) * gh-118692: Avoid creating unnecessary StopIteration instances for monitoring (GH-119216) (cherry picked from commit 6e9863d7a3516cc76d6ce13923b15620499f3855) --------- Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* gh-112075: use per-thread dict version pool (#118676)Dino Viehland2024-05-071-1/+13
| | | use thread state set of dict versions
* gh-118362: Fix thread safety around lookups from the type cache in the face ↵Dino Viehland2024-05-061-1/+2
| | | | | | | of concurrent mutators (#118454) Add _PyType_LookupRef and use incref before setting attribute on type Makes setting an attribute on a class and signaling type modified atomic Avoid adding re-entrancy exposing the type cache in an inconsistent state by decrefing after type is updated
* gh-111997: C-API for signalling monitoring events (#116413)Irit Katriel2024-05-042-0/+508
|
* gh-82062: Fix support of parameter defaults on methods in extension modules ↵Sergey B Kirpichev2024-05-021-0/+10
| | | | | | | | | (GH-115270) Now inspect.signature() supports references to the module globals in parameter defaults on methods in extension modules. Previously it was only supported in functions. The workaround was to specify the fully qualified name, including the module name.
* gh-110850: Add PyTime_TimeRaw() function (#118394)Victor Stinner2024-05-011-0/+60
| | | | | | | | | | | | | | | | | Add "Raw" variant of PyTime functions: * PyTime_MonotonicRaw() * PyTime_PerfCounterRaw() * PyTime_TimeRaw() Changes: * Add documentation and tests. Tests release the GIL while calling raw clock functions. * py_get_system_clock() and py_get_monotonic_clock() now check that the GIL is hold by the caller if raise_exc is non-zero. * Reimplement "Unchecked" functions with raw clock functions. Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-118422: Fix run_fileexflags() test (#118429)Victor Stinner2024-04-301-7/+6
| | | | | Don't test the undefined behavior of fileno() on a closed file, but use fstat() as a reliable test if the file was closed or not.
* gh-117968: Make the test for closed file more safe in the C API tests ↵Serhiy Storchaka2024-04-251-2/+4
| | | | | | | | (GH-118230) The behavior of fileno() after fclose() is undefined, but it is the only practical way to check whether the file was closed. Only test this on the known platforms (Linux, Windows, macOS), where we already tested that it works.
* gh-68114: Fix handling for removed PyArg_ParseTuple 'w' formatters (GH-8204)Joe Jevnik2024-04-231-0/+118
| | | | Co-authored-by: Joe Jevnik <joe@quantopian.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-117968: Add tests for the part of the PyRun family of the C API (GH-117982)Serhiy Storchaka2024-04-172-0/+113
| | | | Co-authored-by: NGRsoftlab <78017794+NGRsoftlab@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-111140: PyLong_From/AsNativeBytes: Take *flags* rather than just ↵Steve Dower2024-04-051-7/+7
| | | | *endianness* (GH-116053)
* gh-94808: Fix refcounting in PyObject_Print tests (GH-117421)Petr Viktorin2024-04-011-0/+4
|
* gh-94808:Improve coverage of PyObject_Print (GH-98749)MonadChains2024-04-012-0/+134
|
* gh-87193: Support bytes objects with refcount > 1 in _PyBytes_Resize() ↵Serhiy Storchaka2024-03-252-0/+54
| | | | | (GH-117160) Create a new bytes object and destroy the old one if it has refcount > 1.
* gh-113024: C API: Add PyObject_GenericHash() function (GH-113025)Serhiy Storchaka2024-03-221-0/+11
|
* gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit ↵Serhiy Storchaka2024-03-201-0/+12
| | | | platforms (GH-117064)
* gh-116417: Move limited C API complex.c tests to _testlimitedcapi (#117014)Victor Stinner2024-03-191-61/+0
| | | | Split complex.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi.
* gh-116417: Move limited C API dict.c tests to _testlimitedcapi (#117006)Victor Stinner2024-03-191-278/+1
| | | | Split dict.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi.
* gh-116417: Move limited C API long.c tests to _testlimitedcapi (#117001)Victor Stinner2024-03-193-1100/+2
| | | | | | | * Split long.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi. * Move testcapi_long.h from Modules/_testcapi/ to Modules/_testlimitedcapi/. * Add MODULE__TESTLIMITEDCAPI_DEPS to Makefile.pre.in.
* gh-116417: Move limited C API unicode.c tests to _testlimitedcapi (#116993)Victor Stinner2024-03-191-1881/+18
| | | | | | Split unicode.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi. Update test_codecs.
* gh-116417: Move limited C API abstract.c tests to _testlimitedcapi (#116986)Victor Stinner2024-03-192-646/+10
| | | | | | | Split abstract.c and float.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi. Update test_bytes and test_class.
* gh-116417: Move limited C API list.c tests to _testlimitedcapi (#116602)Victor Stinner2024-03-182-321/+1
| | | | | Split list.c and set.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi.
* gh-116417: Move 4 limited C API test files to _testlimitedcapi (#116571)Victor Stinner2024-03-115-498/+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: Fix make check-c-globals for _testlimitedcapi (#116570)Victor Stinner2024-03-101-4/+0
| | | | | * Remove unused '_testcapimodule' global in Modules/_testcapi/unicode.c. * Update c-analyzer to not use the internal C API in _testlimitedcapi.c.
* gh-116417: Add _testlimitedcapi C extension (#116419)Victor Stinner2024-03-074-567/+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: Enhance PyTime C API tests (#115715)Victor Stinner2024-02-201-4/+9
|
* gh-115417: Remove accidentally left debugging print (#115418)Kirill Podoprigora2024-02-131-1/+0
| | | gh-115417: Remove debugging print
* gh-111140: Adds PyLong_AsNativeBytes and PyLong_FromNative[Unsigned]Bytes ↵Steve Dower2024-02-121-1/+47
| | | | functions (GH-114886)
* gh-110850: Add PyTime_t C API (GH-115215)Petr Viktorin2024-02-122-0/+106
| | | | | | | | | | | | * 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-112066: Add `PyDict_SetDefaultRef` function. (#112123)Sam Gross2024-02-061-0/+26
| | | | | | | The `PyDict_SetDefaultRef` function is similar to `PyDict_SetDefault`, but returns a strong reference through the optional `**result` pointer instead of a borrowed reference. Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-114329: Add `PyList_GetItemRef` function (GH-114504)Sam Gross2024-02-021-0/+13
| | | | | | | The new `PyList_GetItemRef` is similar to `PyList_GetItem`, but returns a strong reference instead of a borrowed reference. Additionally, if the passed "list" object is not a list, the function sets a `TypeError` instead of calling `PyErr_BadInternalCall()`.
* GH-113710: Add a "globals to constants" pass (GH-114592)Mark Shannon2024-02-021-2/+2
| | | Converts specializations of `LOAD_GLOBAL` into constants during tier 2 optimization.
* gh-114685: Check flags in PyObject_GetBuffer() (GH-114707)Serhiy Storchaka2024-01-311-2/+4
| | | | | PyObject_GetBuffer() now raises a SystemError if called with PyBUF_READ or PyBUF_WRITE as flags. These flags should only be used with the PyMemoryView_* C API.
* gh-114101: Correct PyErr_Format arguments in _testcapi module (#114102)AN Long2024-01-161-2/+2
| | | | - use PyErr_SetString() iso. PyErr_Format() in parse_tuple_and_keywords() - fix misspelled format specifier in CHECK_SIGNNESS() macro
* gh-113787: Fix refleaks in test_capi (gh-113816)neonene2024-01-081-1/+1
| | | Fix refleaks and a typo.
* gh-113750: Fix object resurrection in free-threaded builds (gh-113751)Sam Gross2024-01-061-3/+1
| | | | | | | | | 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.
* bpo-36796: Clean the error handling in _testcapimodule.c (GH-13085)Zackery Spytz2023-12-141-8/+38
|
* gh-111650: Ensure pyconfig.h includes Py_GIL_DISABLED on Windows (GH-112778)Steve Dower2023-12-132-4/+0
|
* gh-111545: Add Py_HashPointer() function (#112096)Victor Stinner2023-12-061-0/+16
| | | | | * Implement _Py_HashPointerRaw() as a static inline function. * Add Py_HashPointer() tests to test_capi.test_hash. * Keep _Py_HashPointer() function as an alias to Py_HashPointer().
* Add more C API tests (GH-112522)Serhiy Storchaka2023-11-291-0/+33
| | | | Add tests for PyObject_Str(), PyObject_Repr(), PyObject_ASCII() and PyObject_Bytes().