[Python-checkins] bpo-21120: Exclude Python-ast.h, ast.h and asdl.h from the limited API (#14634)

Mark Shannon webhook-mailer at python.org
Thu Sep 12 05:27:18 EDT 2019


https://github.com/python/cpython/commit/421a72af4deaec96a49a79951b9c2546a2faa13d
commit: 421a72af4deaec96a49a79951b9c2546a2faa13d
branch: master
author: Zackery Spytz <zspytz at gmail.com>
committer: Mark Shannon <mark at hotpy.org>
date: 2019-09-12T10:27:14+01:00
summary:

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.

files:
A Misc/NEWS.d/next/C API/2019-07-06-23-56-47.bpo-21120.lXHqlT.rst
M Include/Python-ast.h
M Include/asdl.h
M Include/ast.h
M Parser/asdl_c.py

diff --git a/Include/Python-ast.h b/Include/Python-ast.h
index 5fe4f2b4314c..b9232b1d4630 100644
--- a/Include/Python-ast.h
+++ b/Include/Python-ast.h
@@ -6,6 +6,7 @@
 extern "C" {
 #endif
 
+#ifndef Py_LIMITED_API
 #include "asdl.h"
 
 #undef Yield   /* undefine macro conflicting with <winbase.h> */
@@ -708,6 +709,7 @@ type_ignore_ty _Py_TypeIgnore(int lineno, string tag, PyArena *arena);
 PyObject* PyAST_mod2obj(mod_ty t);
 mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);
 int PyAST_Check(PyObject* obj);
+#endif /* !Py_LIMITED_API */
 
 #ifdef __cplusplus
 }
diff --git a/Include/asdl.h b/Include/asdl.h
index fc6d22371b63..549df2ace755 100644
--- a/Include/asdl.h
+++ b/Include/asdl.h
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef Py_ASDL_H
 #define Py_ASDL_H
 
@@ -44,3 +45,4 @@ asdl_int_seq *_Py_asdl_int_seq_new(Py_ssize_t size, PyArena *arena);
 #endif
 
 #endif /* !Py_ASDL_H */
+#endif /* Py_LIMITED_API */
diff --git a/Include/ast.h b/Include/ast.h
index 1347fcffcd75..a8c52af786b1 100644
--- a/Include/ast.h
+++ b/Include/ast.h
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef Py_AST_H
 #define Py_AST_H
 #ifdef __cplusplus
@@ -19,8 +20,6 @@ PyAPI_FUNC(mod_ty) PyAST_FromNodeObject(
     PyObject *filename,
     PyArena *arena);
 
-#ifndef Py_LIMITED_API
-
 /* _PyAST_ExprAsUnicode is defined in ast_unparse.c */
 PyAPI_FUNC(PyObject *) _PyAST_ExprAsUnicode(expr_ty);
 
@@ -29,9 +28,8 @@ PyAPI_FUNC(PyObject *) _PyAST_ExprAsUnicode(expr_ty);
    Doesn't set exception. */
 PyAPI_FUNC(PyObject *) _PyAST_GetDocString(asdl_seq *);
 
-#endif /* !Py_LIMITED_API */
-
 #ifdef __cplusplus
 }
 #endif
 #endif /* !Py_AST_H */
+#endif /* !Py_LIMITED_API */
diff --git a/Misc/NEWS.d/next/C API/2019-07-06-23-56-47.bpo-21120.lXHqlT.rst b/Misc/NEWS.d/next/C API/2019-07-06-23-56-47.bpo-21120.lXHqlT.rst
new file mode 100644
index 000000000000..088a6a8614f3
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2019-07-06-23-56-47.bpo-21120.lXHqlT.rst	
@@ -0,0 +1 @@
+Exclude Python-ast.h, ast.h and asdl.h from the limited API.
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 85d96a33f3ff..6b31ffd8315d 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -1339,6 +1339,7 @@ def main(srcfile, dump_module=False):
             f.write('extern "C" {\n')
             f.write('#endif\n')
             f.write('\n')
+            f.write('#ifndef Py_LIMITED_API\n')
             f.write('#include "asdl.h"\n')
             f.write('\n')
             f.write('#undef Yield   /* undefine macro conflicting with <winbase.h> */\n')
@@ -1353,6 +1354,7 @@ def main(srcfile, dump_module=False):
             f.write("PyObject* PyAST_mod2obj(mod_ty t);\n")
             f.write("mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);\n")
             f.write("int PyAST_Check(PyObject* obj);\n")
+            f.write("#endif /* !Py_LIMITED_API */\n")
             f.write('\n')
             f.write('#ifdef __cplusplus\n')
             f.write('}\n')



More information about the Python-checkins mailing list