Skip to content

Commit 421a72a

Browse files
ZackerySpytzmarkshannon
authored andcommitted
bpo-21120: Exclude Python-ast.h, ast.h and asdl.h from the limited API (#14634)
The PyArena type is not part of the limited API, so these headers shouldn't be part of it either.
1 parent 6954be8 commit 421a72a

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

Include/Python-ast.h

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

Include/asdl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#ifndef Py_LIMITED_API
12
#ifndef Py_ASDL_H
23
#define Py_ASDL_H
34

@@ -44,3 +45,4 @@ asdl_int_seq *_Py_asdl_int_seq_new(Py_ssize_t size, PyArena *arena);
4445
#endif
4546

4647
#endif /* !Py_ASDL_H */
48+
#endif /* Py_LIMITED_API */

Include/ast.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#ifndef Py_LIMITED_API
12
#ifndef Py_AST_H
23
#define Py_AST_H
34
#ifdef __cplusplus
@@ -19,8 +20,6 @@ PyAPI_FUNC(mod_ty) PyAST_FromNodeObject(
1920
PyObject *filename,
2021
PyArena *arena);
2122

22-
#ifndef Py_LIMITED_API
23-
2423
/* _PyAST_ExprAsUnicode is defined in ast_unparse.c */
2524
PyAPI_FUNC(PyObject *) _PyAST_ExprAsUnicode(expr_ty);
2625

@@ -29,9 +28,8 @@ PyAPI_FUNC(PyObject *) _PyAST_ExprAsUnicode(expr_ty);
2928
Doesn't set exception. */
3029
PyAPI_FUNC(PyObject *) _PyAST_GetDocString(asdl_seq *);
3130

32-
#endif /* !Py_LIMITED_API */
33-
3431
#ifdef __cplusplus
3532
}
3633
#endif
3734
#endif /* !Py_AST_H */
35+
#endif /* !Py_LIMITED_API */
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Exclude Python-ast.h, ast.h and asdl.h from the limited API.

Parser/asdl_c.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,7 @@ def main(srcfile, dump_module=False):
13391339
f.write('extern "C" {\n')
13401340
f.write('#endif\n')
13411341
f.write('\n')
1342+
f.write('#ifndef Py_LIMITED_API\n')
13421343
f.write('#include "asdl.h"\n')
13431344
f.write('\n')
13441345
f.write('#undef Yield /* undefine macro conflicting with <winbase.h> */\n')
@@ -1353,6 +1354,7 @@ def main(srcfile, dump_module=False):
13531354
f.write("PyObject* PyAST_mod2obj(mod_ty t);\n")
13541355
f.write("mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);\n")
13551356
f.write("int PyAST_Check(PyObject* obj);\n")
1357+
f.write("#endif /* !Py_LIMITED_API */\n")
13561358
f.write('\n')
13571359
f.write('#ifdef __cplusplus\n')
13581360
f.write('}\n')

0 commit comments

Comments
 (0)