cpython/Modules/_testcapi
Victor Stinner be5e8a0103
gh-110964: Remove private _PyArg functions (#110966)
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
2023-10-17 14:30:31 +02:00
..
clinic gh-110964: Remove private _PyArg functions (#110966) 2023-10-17 14:30:31 +02:00
abstract.c gh-110549: Remove unused includes of <stddef.h> in _testcapi (GH-110552) 2023-10-09 10:37:57 +00:00
buffer.c gh-106869: Use new PyMemberDef constant names (#106871) 2023-07-25 15:28:30 +02:00
code.c C API tests: use special markers to test that output parameters were set (GH-109014) 2023-09-06 22:02:01 +03:00
datetime.c gh-99300: Replace Py_INCREF() with Py_NewRef() (#99513) 2022-11-16 10:39:47 +01:00
dict.c gh-110549: Remove unused includes of <stddef.h> in _testcapi (GH-110552) 2023-10-09 10:37:57 +00:00
docstring.c gh-107782: Use _testcapi to test non-representable signatures (GH-109325) 2023-09-14 09:12:17 +03:00
exceptions.c gh-110964: Remove private _PyArg functions (#110966) 2023-10-17 14:30:31 +02:00
float.c gh-110964: Remove private _PyArg functions (#110966) 2023-10-17 14:30:31 +02: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-110815: Improve tests for PyArg_ParseTupleAndKeywords() (GH-110817) 2023-10-13 16:05:01 +03:00
heaptype.c gh-107073: Make PyObject_VisitManagedDict() public (#108763) 2023-10-02 19:24:08 +02:00
heaptype_relative.c gh-109045: Remove remaining LIMITED_API_AVAILABLE checks in tests (#109046) 2023-09-07 04:42:58 +02:00
immortal.c Trim trailing whitespace and test on CI (#104275) 2023-05-08 17:03:52 +03:00
long.c gh-110628: Add tests for PyLong C API (GH-110629) 2023-10-14 08:53:57 +03:00
mem.c gh-106320: Remove private _PyMem API (#107187) 2023-07-24 18:48:06 +00:00
parts.h gh-110964: Remove private _PyArg functions (#110966) 2023-10-17 14:30:31 +02:00
pyatomic.c gh-109693: Update _gil_runtime_state.locked to use pyatomic.h (gh-110836) 2023-10-17 07:32:50 +09:00
pyos.c GH-94808: Cover PyOS_mystrnicmp and PyOS_mystricmp (gh-102469) 2023-03-22 20:35:27 +09:00
README.txt gh-104469: Update README.txt for _testcapi (gh-104529) 2023-05-17 12:56:20 +09:00
set.c gh-110525: Cover PySet_Add corner case with frozenset objects (GH-110544) 2023-10-09 14:04:49 +03: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-110289: C API: Add PyUnicode_EqualToUTF8() and PyUnicode_EqualToUTF8AndSize() functions (GH-110297) 2023-10-11 16:41:58 +03:00
util.h gh-109469: Silence compiler warnings on string comparisons in _testcapi (GH-109533) 2023-09-19 08:12:29 +03:00
vectorcall.c gh-110964: Remove private _PyArg functions (#110966) 2023-10-17 14:30:31 +02:00
vectorcall_limited.c gh-104469: Convert _testcapi/vectorcall_limited.c to use AC (#109691) 2023-09-25 13:24:19 +02:00
watchers.c gh-110964: Remove private _PyArg functions (#110966) 2023-10-17 14:30:31 +02: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.