Skip to content

Commit

Permalink
pythongh-107603: Argument Clinic: Only include pycore_gc.h if needed (p…
Browse files Browse the repository at this point in the history
…ython#108726)

Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed,
and only includes pycore_runtime.h if _Py_ID() is needed.

* Add 'condition' optional argument to Clinic.add_include().
* deprecate_keyword_use() includes pycore_runtime.h when using
  the _PyID() function.
* Fix rendering of includes: comments start at the column 35.
* Mark PC/clinic/_wmimodule.cpp.h and
  "Objects/stringlib/clinic/*.h.h" header files as generated in
  .gitattributes.

Effects:

* 42 header files generated by AC no longer include the internal C
  API, instead of 4 header files before. For example,
  Modules/clinic/_abc.c.h no longer includes the internal C API.
* Fix _testclinic_depr.c.h: it now always includes pycore_runtime.h
  to get _Py_ID().
  • Loading branch information
vstinner authored Aug 31, 2023
1 parent 2bd960b commit ad73674
Show file tree
Hide file tree
Showing 131 changed files with 448 additions and 727 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ PCbuild/readme.txt dos
[attr]generated linguist-generated=true diff=generated

**/clinic/*.c.h generated
**/clinic/*.cpp.h generated
**/clinic/*.h.h generated
*_db.h generated
Doc/data/stable_abi.dat generated
Doc/library/token-list.inc generated
Expand Down
8 changes: 1 addition & 7 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2673,12 +2673,6 @@ def test_file_dest(self):
preserve
[clinic start generated code]*/
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_gc.h" // PyGC_Head
# include "pycore_runtime.h" // _Py_ID()
#endif
PyDoc_VAR(func__doc__);
PyDoc_STRVAR(func__doc__,
Expand All @@ -2691,7 +2685,7 @@ def test_file_dest(self):
static PyObject *
func(PyObject *module, PyObject *a)
/*[clinic end generated code: output=56c09670e89a0d9a input=a9049054013a1b77]*/
/*[clinic end generated code: output=3dde2d13002165b9 input=a9049054013a1b77]*/
""")
with os_helper.temp_dir() as tmp_dir:
in_fn = os.path.join(tmp_dir, "test.c")
Expand Down
9 changes: 4 additions & 5 deletions Modules/_blake2/clinic/blake2b_impl.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Modules/_blake2/clinic/blake2s_impl.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions Modules/_ctypes/clinic/callproc.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Modules/_io/clinic/_iomodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Modules/_io/clinic/bufferedio.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Modules/_io/clinic/bytesio.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Modules/_io/clinic/fileio.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions Modules/_io/clinic/iobase.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Modules/_io/clinic/stringio.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Modules/_io/clinic/textio.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Modules/_io/clinic/winconsoleio.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions Modules/_multiprocessing/clinic/multiprocessing.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Modules/_multiprocessing/clinic/posixshmem.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Modules/_multiprocessing/clinic/semaphore.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Modules/_sqlite/clinic/_sqlite3.connect.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions Modules/_sqlite/clinic/blob.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Modules/_sqlite/clinic/connection.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Modules/_sqlite/clinic/cursor.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ad73674

Please sign in to comment.