]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35134: Remove the Include/code.h header file (GH-32385)
authorVictor Stinner <vstinner@python.org>
Thu, 7 Apr 2022 00:29:52 +0000 (02:29 +0200)
committerGitHub <noreply@github.com>
Thu, 7 Apr 2022 00:29:52 +0000 (02:29 +0200)
Remove the Include/code.h header file. C extensions should only
include the main <Python.h> header file.

Python.h includes directly Include/cpython/code.h instead.

14 files changed:
Doc/whatsnew/3.11.rst
Include/Python.h
Include/code.h [deleted file]
Include/cpython/code.h
Makefile.pre.in
Misc/NEWS.d/next/C API/2022-04-07-00-53-51.bpo-35134.zSjIzk.rst [new file with mode: 0644]
Objects/codeobject.c
PCbuild/pythoncore.vcxproj
PCbuild/pythoncore.vcxproj.filters
Python/ceval.c
Python/marshal.c
Python/pythonrun.c
Python/sysmodule.c
Python/traceback.c

index 4c9b32d9a94521e5a32a7e9318c23b643b2d9b0f..31cdf10f66656ef18390455777d78d27c60a5a27 100644 (file)
@@ -1210,7 +1210,7 @@ Porting to Python 3.11
   explicitly include the header files after ``#include <Python.h>``.
   (Contributed by Victor Stinner in :issue:`45434`.)
 
-* The non-limited API files ``cellobject.h``, ``classobject.h``, ``context.h``,
+* The non-limited API files ``cellobject.h``, ``classobject.h``, ``code.h``, ``context.h``,
   ``funcobject.h``, ``genobject.h`` and ``longintrepr.h`` have been moved to
   the ``Include/cpython`` directory. Moreover, the ``eval.h`` header file was
   removed. These files must not be included directly, as they are already
index 4dc2edb4dbbe235296c553a5757a526895661c31..52a7aac6ba6cb6eb845512a033b94165ef3b4fa8 100644 (file)
@@ -68,7 +68,7 @@
 #include "cpython/classobject.h"
 #include "fileobject.h"
 #include "pycapsule.h"
-#include "code.h"
+#include "cpython/code.h"
 #include "pyframe.h"
 #include "traceback.h"
 #include "sliceobject.h"
diff --git a/Include/code.h b/Include/code.h
deleted file mode 100644 (file)
index 0245c32..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Definitions for bytecode */
-
-#ifndef Py_CODE_H
-#define Py_CODE_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef Py_LIMITED_API
-#  define Py_CPYTHON_CODE_H
-#  include "cpython/code.h"
-#  undef Py_CPYTHON_CODE_H
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* !Py_CODE_H */
index 157678317931ec41fb469efa01754f4d3d2e5d5e..6dc2290ffeb5e2c2542f329c5f51773659cf9c26 100644 (file)
@@ -1,5 +1,10 @@
-#ifndef Py_CPYTHON_CODE_H
-#  error "this header file must not be included directly"
+/* Definitions for bytecode */
+
+#ifndef Py_LIMITED_API
+#ifndef Py_CODE_H
+#define Py_CODE_H
+#ifdef __cplusplus
+extern "C" {
 #endif
 
 /* Each instruction in a code object is a fixed-width value,
@@ -204,3 +209,9 @@ PyAPI_FUNC(int) _PyCode_GetExtra(PyObject *code, Py_ssize_t index,
                                  void **extra);
 PyAPI_FUNC(int) _PyCode_SetExtra(PyObject *code, Py_ssize_t index,
                                  void *extra);
+
+#ifdef __cplusplus
+}
+#endif
+#endif  // !Py_CODE_H
+#endif  // !Py_LIMITED_API
index 2f61259e69b8cf056eed11c295e11bd8e95cc519..cb6e962045a04282bfecbde50fca62f3060a3cf8 100644 (file)
@@ -1450,7 +1450,6 @@ PYTHON_HEADERS= \
                $(srcdir)/Include/bytearrayobject.h \
                $(srcdir)/Include/bytesobject.h \
                $(srcdir)/Include/ceval.h \
-               $(srcdir)/Include/code.h \
                $(srcdir)/Include/codecs.h \
                $(srcdir)/Include/compile.h \
                $(srcdir)/Include/complexobject.h \
diff --git a/Misc/NEWS.d/next/C API/2022-04-07-00-53-51.bpo-35134.zSjIzk.rst b/Misc/NEWS.d/next/C API/2022-04-07-00-53-51.bpo-35134.zSjIzk.rst
new file mode 100644 (file)
index 0000000..93e6e32
--- /dev/null
@@ -0,0 +1,2 @@
+Remove the ``Include/code.h`` header file. C extensions should only include
+the main ``<Python.h>`` header file. Patch by Victor Stinner.
index 7d50b40ec45367e82eb876660f19b0f85cac7d43..e872b398e08c8d619710111a780209200c9081df 100644 (file)
@@ -1,7 +1,6 @@
 #include <stdbool.h>
 
 #include "Python.h"
-#include "code.h"
 #include "opcode.h"
 #include "structmember.h"         // PyMemberDef
 #include "pycore_code.h"          // _PyCodeConstructor
index 6e51e17194d4dbec169fdcee4b181394e25fbfa6..cbd3936860120875f17c013e29c40b490650ac31 100644 (file)
     <ClInclude Include="..\Include\bytearrayobject.h" />
     <ClInclude Include="..\Include\bytesobject.h" />
     <ClInclude Include="..\Include\ceval.h" />
-    <ClInclude Include="..\Include\code.h" />
     <ClInclude Include="..\Include\codecs.h" />
     <ClInclude Include="..\Include\compile.h" />
     <ClInclude Include="..\Include\complexobject.h" />
index 5fe6a9de21c13c9389f8328a26ab208824eb4959..70af3052221708d0406300821fe8cef297a2a26d 100644 (file)
     <ClInclude Include="..\Include\objimpl.h">
       <Filter>Include</Filter>
     </ClInclude>
-    <ClInclude Include="..\Include\opcode.h">
-      <Filter>Include</Filter>
-    </ClInclude>
     <ClInclude Include="..\Include\osdefs.h">
       <Filter>Include</Filter>
     </ClInclude>
index 487e09bc66417344fac50b116e03abbe48a3243d..5384aac5d6e6cb4b061c163eb88e858a9e248747 100644 (file)
@@ -23,7 +23,6 @@
 #include "pycore_tuple.h"         // _PyTuple_ITEMS()
 #include "pycore_emscripten_signal.h"  // _Py_CHECK_EMSCRIPTEN_SIGNALS
 
-#include "code.h"
 #include "pycore_dict.h"
 #include "dictobject.h"
 #include "frameobject.h"
index e7cf6553bd142fbd0c280d93c09b8eb74deda43f..19abcc8ffe4b763ea7106ea5a2a9bac468bef6d7 100644 (file)
@@ -12,7 +12,6 @@
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
 #include "pycore_code.h"          // _PyCode_New()
 #include "pycore_hashtable.h"     // _Py_hashtable_t
-#include "code.h"
 #include "marshal.h"              // Py_MARSHAL_VERSION
 
 /*[clinic input]
index 38ca952838a1f4584100407ff22737912e3369fe..d117b790dfdaaebb9b2d85ad30d4a51b0a3e4009 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "token.h"                // INDENT
 #include "errcode.h"              // E_EOF
-#include "code.h"                 // PyCodeObject
 #include "marshal.h"              // PyMarshal_ReadLongFromFile()
 
 #ifdef MS_WINDOWS
index de4e10a7e110caa5f95ba4b7d378513a00618dbf..ac44b803b23f553808260c475c52987ad5053d99 100644 (file)
@@ -31,7 +31,6 @@ Data members:
 #include "pycore_structseq.h"     // _PyStructSequence_InitType()
 #include "pycore_tuple.h"         // _PyTuple_FromArray()
 
-#include "code.h"
 #include "frameobject.h"          // PyFrame_GetBack()
 #include "pydtrace.h"
 #include "osdefs.h"               // DELIM
index 0d0eb954c232f8a7a79294200b04a0edb69f0e6d..488c1b17cf51ffe9ec08dd17a96782db9cd8861e 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "Python.h"
 
-#include "code.h"                 // PyCode_Addr2Line etc
 #include "frameobject.h"          // PyFrame_GetBack()
 #include "pycore_ast.h"           // asdl_seq_*
 #include "pycore_call.h"          // _PyObject_CallMethodFormat()