cpython/Modules/_testcapi
Victor Stinner 13a00078b8
gh-108634: Py_TRACE_REFS uses a hash table (#108663)
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().
2023-08-31 18:33:34 +02:00
..
clinic gh-108444: Argument Clinic uses PyLong_AsInt() (#108458) 2023-08-25 00:51:22 +02:00
abstract.c gh-107178: Add the C API tests for the Abstract Objects Layer (GH-107179) 2023-08-07 18:51:43 +03:00
buffer.c gh-106869: Use new PyMemberDef constant names (#106871) 2023-07-25 15:28:30 +02:00
code.c gh-106320: Remove _PyDict_GetItemStringWithError() function (#108313) 2023-08-22 18:17:25 +00:00
datetime.c gh-99300: Replace Py_INCREF() with Py_NewRef() (#99513) 2022-11-16 10:39:47 +01:00
dict.c gh-108314: Add PyDict_ContainsString() function (#108323) 2023-08-24 15:59:12 +02:00
docstring.c gh-84805: Autogenerate signature for METH_NOARGS and METH_O extension functions (GH-107794) 2023-08-11 18:08:38 +03:00
exceptions.c gh-107915: Handle errors in C API functions PyErr_Set*() and PyErr_Format() (GH-107918) 2023-08-19 14:51:03 +03:00
float.c gh-104922: remove PY_SSIZE_T_CLEAN (#106315) 2023-07-02 15:07:46 +09:00
gc.c gh-93649: Split gc- and allocation tests from _testcapimodule.c (GH-104403) 2023-05-12 10:26:07 +01:00
getargs.c gh-104922: remove PY_SSIZE_T_CLEAN (#106315) 2023-07-02 15:07:46 +09:00
heaptype.c gh-106869: Use new PyMemberDef constant names (#106871) 2023-07-25 15:28:30 +02:00
heaptype_relative.c gh-103509: PEP 697 -- Limited C API for Extending Opaque Types (GH-103511) 2023-05-04 09:56:53 +02:00
immortal.c Trim trailing whitespace and test on CI (#104275) 2023-05-08 17:03:52 +03:00
long.c gh-108444: Add PyLong_AsInt() public function (#108445) 2023-08-24 23:55:30 +02:00
mem.c gh-106320: Remove private _PyMem API (#107187) 2023-07-24 18:48:06 +00:00
parts.h gh-108634: Py_TRACE_REFS uses a hash table (#108663) 2023-08-31 18:33:34 +02:00
pyos.c GH-94808: Cover PyOS_mystrnicmp and PyOS_mystricmp (gh-102469) 2023-03-22 20:35:27 +09:00
pytime.c gh-106316: Remove pytime.h header file (#106317) 2023-07-01 22:27:18 +00:00
README.txt gh-104469: Update README.txt for _testcapi (gh-104529) 2023-05-17 12:56:20 +09:00
structmember.c gh-47146: Fix reference counting in _testcapi.structmember initializer (GH-106862) 2023-07-21 12:30:14 +03:00
testcapi_long.h gh-93649: Split float/long tests from _testcapimodule.c (GH-99549) 2022-11-17 00:56:56 -08:00
unicode.c gh-99593: Add tests for Unicode C API (part 3) (GH-104728) 2023-07-10 14:04:34 +03:00
vectorcall.c gh-107609: Fix duplicate module check in Argument Clinic (#107610) 2023-08-04 07:28:25 +02:00
vectorcall_limited.c Revert "gh-104469 : Convert _testcapi/vectorcall_limited.c to use AC … (gh-107951) 2023-08-14 23:25:57 +00:00
watchers.c gh-91054: make code watcher tests resilient to other watchers (#107821) 2023-08-09 16:42:32 -06:00

Tests in this directory are compiled into the _testcapi extension.
The main file for the extension is Modules/_testcapimodule.c, which
calls `_PyTestCapi_Init_*` from these functions.

General guideline when writing test code for C API.
* Use Argument Clinic to minimise the amount of boilerplate code.
* Add a newline between the argument spec and the docstring.
* If a test description is needed, make sure the added docstring clearly and succinctly describes purpose of the function.
* DRY, use the clone feature of Argument Clinic.
* Try to avoid adding new interned strings; reuse existing parameter names if possible. Use the `as` feature of Argument Clinic to override the C variable name, if needed.