Skip to content

Commit df2c754

Browse files
committed
gh-107603: AC only includes pycore_gc.h if needed
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 Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI macro to opt-out for the internal C API in Argument Clinic. The following extensions avoids the internal C API by defining the macro Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI: * Modules/_csv.c * Modules/_multiprocessing/posixshmem.c * Modules/_testcapi/exceptions.c * Modules/grpmodule.c * Modules/syslogmodule.c
1 parent bd58389 commit df2c754

File tree

139 files changed

+288
-1030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+288
-1030
lines changed

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ struct _Py_global_strings {
408408
STRUCT_FOR_ID(extend)
409409
STRUCT_FOR_ID(extra_tokens)
410410
STRUCT_FOR_ID(f)
411-
STRUCT_FOR_ID(facility)
412411
STRUCT_FOR_ID(factory)
413412
STRUCT_FOR_ID(false)
414413
STRUCT_FOR_ID(family)
@@ -460,8 +459,6 @@ struct _Py_global_strings {
460459
STRUCT_FOR_ID(headers)
461460
STRUCT_FOR_ID(hi)
462461
STRUCT_FOR_ID(hook)
463-
STRUCT_FOR_ID(id)
464-
STRUCT_FOR_ID(ident)
465462
STRUCT_FOR_ID(ignore)
466463
STRUCT_FOR_ID(imag)
467464
STRUCT_FOR_ID(importlib)
@@ -524,7 +521,6 @@ struct _Py_global_strings {
524521
STRUCT_FOR_ID(lo)
525522
STRUCT_FOR_ID(locale)
526523
STRUCT_FOR_ID(locals)
527-
STRUCT_FOR_ID(logoption)
528524
STRUCT_FOR_ID(loop)
529525
STRUCT_FOR_ID(mapping)
530526
STRUCT_FOR_ID(match)
@@ -560,7 +556,6 @@ struct _Py_global_strings {
560556
STRUCT_FOR_ID(narg)
561557
STRUCT_FOR_ID(ndigits)
562558
STRUCT_FOR_ID(new_file_name)
563-
STRUCT_FOR_ID(new_limit)
564559
STRUCT_FOR_ID(newline)
565560
STRUCT_FOR_ID(newlines)
566561
STRUCT_FOR_ID(next)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_clinic.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323

2424
def _make_clinic(*, filename='clinic_tests'):
2525
clang = clinic.CLanguage(None)
26-
c = clinic.Clinic(clang, filename=filename, limited_capi=False)
26+
c = clinic.Clinic(clang,
27+
filename=filename,
28+
limited_capi=False,
29+
internal_capi=True)
2730
c.block_parser = clinic.BlockParser('', clang)
2831
return c
2932

@@ -125,7 +128,7 @@ def test_parse_with_body_prefix(self):
125128
clang.body_prefix = "//"
126129
clang.start_line = "//[{dsl_name} start]"
127130
clang.stop_line = "//[{dsl_name} stop]"
128-
cl = clinic.Clinic(clang, filename="test.c", limited_capi=False)
131+
cl = clinic.Clinic(clang, filename="test.c", limited_capi=False, internal_capi=True)
129132
raw = dedent("""
130133
//[clinic start]
131134
//module test
@@ -834,7 +837,7 @@ def _test(self, input, output):
834837
writer = clinic.BlockPrinter(language)
835838
c = _make_clinic()
836839
for block in blocks:
837-
writer.print_block(block, limited_capi=c.limited_capi, header_includes=c.includes)
840+
writer.print_block(block, header_includes=c.includes)
838841
output = writer.f.getvalue()
839842
assert output == input, "output != input!\n\noutput " + repr(output) + "\n\n input " + repr(input)
840843

@@ -860,7 +863,10 @@ def test_round_trip_2(self):
860863

861864
def _test_clinic(self, input, output):
862865
language = clinic.CLanguage(None)
863-
c = clinic.Clinic(language, filename="file", limited_capi=False)
866+
c = clinic.Clinic(language,
867+
filename="file",
868+
limited_capi=False,
869+
internal_capi=True)
864870
c.parsers['inert'] = InertParser(c)
865871
c.parsers['copy'] = CopyParser(c)
866872
computed = c.parse(input)
@@ -2673,12 +2679,6 @@ def test_file_dest(self):
26732679
preserve
26742680
[clinic start generated code]*/
26752681
2676-
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
2677-
# include "pycore_gc.h" // PyGC_Head
2678-
# include "pycore_runtime.h" // _Py_ID()
2679-
#endif
2680-
2681-
26822682
PyDoc_VAR(func__doc__);
26832683
26842684
PyDoc_STRVAR(func__doc__,
@@ -2691,7 +2691,7 @@ def test_file_dest(self):
26912691
26922692
static PyObject *
26932693
func(PyObject *module, PyObject *a)
2694-
/*[clinic end generated code: output=56c09670e89a0d9a input=a9049054013a1b77]*/
2694+
/*[clinic end generated code: output=3dde2d13002165b9 input=a9049054013a1b77]*/
26952695
""")
26962696
with os_helper.temp_dir() as tmp_dir:
26972697
in_fn = os.path.join(tmp_dir, "test.c")

Modules/_blake2/clinic/blake2b_impl.c.h

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_blake2/clinic/blake2s_impl.c.h

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_csv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ module instead.
1010

1111
#define MODULE_VERSION "1.0"
1212

13+
// Argument Clinic avoids the internal C API
14+
#define Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI
15+
1316
#include "Python.h"
1417

1518
#include <stddef.h> // offsetof()

Modules/_ctypes/clinic/callproc.c.h

Lines changed: 1 addition & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/_iomodule.c.h

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/bufferedio.c.h

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/bytesio.c.h

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/fileio.c.h

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/iobase.c.h

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/stringio.c.h

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)