cpython/Lib/test/test_capi
Eric Snow 0d5fe2c7b4
[3.12] gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across Interpreters (gh-119331) (gh-119425)
_PyArg_Parser holds static global data generated for modules by Argument Clinic.  The _PyArg_Parser.kwtuple field is a tuple object, even though it's stored within a static global.  In some cases the tuple is statically allocated and thus it's okay that it gets shared by multiple interpreters.  However, in other cases the tuple is set lazily, allocated from the heap using the active interprepreter at the point the tuple is needed.

This is a problem once that interpreter is destroyed since _PyArg_Parser.kwtuple becomes at dangling pointer, leading to crashes.  It isn't a problem if the tuple is allocated under the main interpreter, since its lifetime is bound to the lifetime of the runtime.  The solution here is to temporarily switch to the main interpreter.  The alternative would be to always statically allocate the tuple.

This change also fixes a bug where only the most recent parser was added to the global linked list.

(cherry picked from commit 81865002ae)
2024-05-22 22:26:58 +00:00
..
__init__.py
__main__.py
check_config.py [3.12] gh-104621: Check for Incompatible Extensions in import_find_extension() (gh-107184) (gh-107360) 2023-07-27 21:51:34 +00:00
test_abstract.py [3.12] Add more C API tests (GH-112522) (GH-112525) 2023-11-29 22:02:57 +02:00
test_bytearray.py [3.12] gh-111495: Test C API functions with extreme sizes and indices (GH-111631) (GH-111731) 2023-11-04 12:28:34 +02:00
test_bytes.py [3.12] gh-111495: Test C API functions with extreme sizes and indices (GH-111631) (GH-111731) 2023-11-04 12:28:34 +02:00
test_codecs.py [3.12] gh-99593: Add tests for Unicode C API (part 3) (GH-104728) (GH-106595) 2023-07-10 20:58:58 +03:00
test_complex.py [3.12] gh-109802: Increase test coverage for complexobject.c (GH-112452) (GH-112489) 2023-11-28 08:33:44 +00:00
test_dict.py [3.12] gh-115142: Skip test_capi.test_dict.py if _testcapi is not available (GH-117588) (GH-117718) 2024-04-11 16:18:28 +02:00
test_eval_code_ex.py [3.12] gh-117694: Improve tests for PyEval_EvalCodeEx() (GH-117695) (GH-117884) 2024-04-15 10:02:43 +00:00
test_exceptions.py [3.12] gh-108082: C API: Add tests for PyErr_WriteUnraisable() (GH-111455) (GH-111507) 2023-10-30 17:36:00 +00:00
test_float.py [3.12] gh-111765: Move old PyFloat_* tests to Lib/test/test_capi/test_float.py (GH-111766) (GH-111818) 2023-11-07 12:06:21 +00:00
test_getargs.py [3.12] gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across Interpreters (gh-119331) (gh-119425) 2024-05-22 22:26:58 +00:00
test_immortal.py gh-84436: Add integration C API tests for immortal objects (gh-103962) 2023-05-03 00:05:30 +09:00
test_list.py [3.12] gh-111495: Add tests for PyList C API (GH-111562) (GH-111861) 2023-11-08 18:10:13 +00:00
test_long.py [3.12] gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms (GH-117064) (GH-117070) 2024-03-20 16:44:05 +02:00
test_mem.py gh-93649: Split tracemalloc tests from _testcapimodule.c (#99551) 2022-12-17 09:53:36 +01:00
test_misc.py [3.12] gh-116656: Fix test_capi test_py_config_isoloated_per_interpreter() (GH-116658) (#116668) 2024-03-12 19:06:32 +01:00
test_run.py [3.12] gh-117968: Add tests for the part of the PyRun family of the C API (GH-117982) (GH-118011) 2024-04-22 18:59:28 +00:00
test_set.py [3.12] gh-110525: Add CAPI tests for set and frozenset objects (GH-110526). (GH-110547) 2023-10-09 10:04:09 +00:00
test_structmembers.py [3.12] gh-115011: Improve support of __index__() in setters of members with unsigned integer type (GH-115029) (GH-115294) 2024-02-11 11:56:17 +00:00
test_sys.py [3.12] gh-111065: Add more tests for the C API with the PySys_ prefix (GH-111067) (GH-111305) 2023-10-25 09:10:03 +00:00
test_unicode.py [3.12] gh-111495: Test C API functions with extreme sizes and indices (GH-111631) (GH-111731) 2023-11-04 12:28:34 +02:00
test_watchers.py [3.12] gh-91051: fix type watcher test to be robust to existing watcher (GH-107989) (#108053) 2023-08-17 01:18:24 +02:00