[Python-checkins] bpo-35081: Move bytes_methods.h to the internal C API (GH-18492)

Victor Stinner webhook-mailer at python.org
Wed Feb 12 16:32:38 EST 2020


https://github.com/python/cpython/commit/45876a90e2663f12b90c2090ec3e48bd97841aae
commit: 45876a90e2663f12b90c2090ec3e48bd97841aae
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-02-12T22:32:34+01:00
summary:

bpo-35081: Move bytes_methods.h to the internal C API (GH-18492)

Move the bytes_methods.h header file to the internal C API as
pycore_bytes_methods.h: it only contains private symbols (prefixed by
"_Py"), except of the PyDoc_STRVAR_shared() macro.

files:
A Include/internal/pycore_bytes_methods.h
A Misc/NEWS.d/next/C API/2020-02-12-21-38-49.bpo-35081.5tj1yC.rst
D Include/bytes_methods.h
M Makefile.pre.in
M Objects/bytearrayobject.c
M Objects/bytes_methods.c
M Objects/bytesobject.c
M Objects/stringlib/ctype.h
M Objects/unicodeobject.c
M PCbuild/pythoncore.vcxproj
M PCbuild/pythoncore.vcxproj.filters

diff --git a/Include/bytes_methods.h b/Include/internal/pycore_bytes_methods.h
similarity index 97%
rename from Include/bytes_methods.h
rename to Include/internal/pycore_bytes_methods.h
index 8434a50a4bba7..11e8ab20e9136 100644
--- a/Include/bytes_methods.h
+++ b/Include/internal/pycore_bytes_methods.h
@@ -2,6 +2,10 @@
 #ifndef Py_BYTES_CTYPE_H
 #define Py_BYTES_CTYPE_H
 
+#ifndef Py_BUILD_CORE
+#  error "this header requires Py_BUILD_CORE define"
+#endif
+
 /*
  * The internal implementation behind PyBytes (bytes) and PyByteArray (bytearray)
  * methods of the given names, they operate on ASCII byte strings.
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 3da104bac87d0..aae93ff82c145 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -970,7 +970,6 @@ PYTHON_HEADERS= \
 		$(srcdir)/Include/bltinmodule.h \
 		$(srcdir)/Include/boolobject.h \
 		$(srcdir)/Include/bytearrayobject.h \
-		$(srcdir)/Include/bytes_methods.h \
 		$(srcdir)/Include/bytesobject.h \
 		$(srcdir)/Include/cellobject.h \
 		$(srcdir)/Include/ceval.h \
@@ -1077,6 +1076,7 @@ PYTHON_HEADERS= \
 		\
 		$(srcdir)/Include/internal/pycore_accu.h \
 		$(srcdir)/Include/internal/pycore_atomic.h \
+		$(srcdir)/Include/internal/pycore_bytes_methods.h \
 		$(srcdir)/Include/internal/pycore_call.h \
 		$(srcdir)/Include/internal/pycore_ceval.h \
 		$(srcdir)/Include/internal/pycore_code.h \
diff --git a/Misc/NEWS.d/next/C API/2020-02-12-21-38-49.bpo-35081.5tj1yC.rst b/Misc/NEWS.d/next/C API/2020-02-12-21-38-49.bpo-35081.5tj1yC.rst
new file mode 100644
index 0000000000000..6be33200d9e2b
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2020-02-12-21-38-49.bpo-35081.5tj1yC.rst	
@@ -0,0 +1,3 @@
+Move the ``bytes_methods.h`` header file to the internal C API as
+``pycore_bytes_methods.h``: it only contains private symbols (prefixed by
+``_Py``), except of the ``PyDoc_STRVAR_shared()`` macro.
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index a3fc35ca4d22a..d3964358bc59d 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2,11 +2,11 @@
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
+#include "pycore_bytes_methods.h"
 #include "pycore_object.h"
 #include "pycore_pymem.h"
 #include "pycore_pystate.h"
 #include "structmember.h"
-#include "bytes_methods.h"
 #include "bytesobject.h"
 #include "pystrhex.h"
 
diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c
index db030be4fe756..a4b3868e72522 100644
--- a/Objects/bytes_methods.c
+++ b/Objects/bytes_methods.c
@@ -1,6 +1,6 @@
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
-#include "bytes_methods.h"
+#include "pycore_bytes_methods.h"
 
 PyDoc_STRVAR_shared(_Py_isspace__doc__,
 "B.isspace() -> bool\n\
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index df3eddae6a36d..bd8af72ade5d3 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -3,11 +3,11 @@
 #define PY_SSIZE_T_CLEAN
 
 #include "Python.h"
+#include "pycore_bytes_methods.h"
 #include "pycore_object.h"
 #include "pycore_pymem.h"
 #include "pycore_pystate.h"
 
-#include "bytes_methods.h"
 #include "pystrhex.h"
 #include <stddef.h>
 
diff --git a/Objects/stringlib/ctype.h b/Objects/stringlib/ctype.h
index 843cfa22a8454..9b319b07d11bc 100644
--- a/Objects/stringlib/ctype.h
+++ b/Objects/stringlib/ctype.h
@@ -2,7 +2,7 @@
 # error "ctype.h only compatible with byte-wise strings"
 #endif
 
-#include "bytes_methods.h"
+#include "pycore_bytes_methods.h"
 
 static PyObject*
 stringlib_isspace(PyObject *self, PyObject *Py_UNUSED(ignored))
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 8470e41624bd4..11fa1fb5ff798 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -40,6 +40,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
+#include "pycore_bytes_methods.h"
 #include "pycore_fileutils.h"
 #include "pycore_initconfig.h"
 #include "pycore_object.h"
@@ -47,7 +48,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "pycore_pylifecycle.h"
 #include "pycore_pystate.h"
 #include "ucnhash.h"
-#include "bytes_methods.h"
 #include "stringlib/eq.h"
 
 #ifdef MS_WINDOWS
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 36a27f467405d..a3719d8558de7 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -115,7 +115,6 @@
     <ClInclude Include="..\Include\ast.h" />
     <ClInclude Include="..\Include\bitset.h" />
     <ClInclude Include="..\Include\boolobject.h" />
-    <ClInclude Include="..\Include\bytes_methods.h" />
     <ClInclude Include="..\Include\bytearrayobject.h" />
     <ClInclude Include="..\Include\bytesobject.h" />
     <ClInclude Include="..\Include\cellobject.h" />
@@ -161,6 +160,7 @@
     <ClInclude Include="..\Include\import.h" />
     <ClInclude Include="..\Include\internal\pycore_accu.h" />
     <ClInclude Include="..\Include\internal\pycore_atomic.h" />
+    <ClInclude Include="..\Include\internal\pycore_bytes_methods.h" />
     <ClInclude Include="..\Include\internal\pycore_call.h" />
     <ClInclude Include="..\Include\internal\pycore_ceval.h" />
     <ClInclude Include="..\Include\internal\pycore_code.h" />
diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters
index 0301557b3e50d..67e223dab4396 100644
--- a/PCbuild/pythoncore.vcxproj.filters
+++ b/PCbuild/pythoncore.vcxproj.filters
@@ -48,9 +48,6 @@
     <ClInclude Include="..\Include\boolobject.h">
       <Filter>Include</Filter>
     </ClInclude>
-    <ClInclude Include="..\Include\bytes_methods.h">
-      <Filter>Include</Filter>
-    </ClInclude>
     <ClInclude Include="..\Include\bytearrayobject.h">
       <Filter>Include</Filter>
     </ClInclude>
@@ -186,6 +183,9 @@
     <ClInclude Include="..\Include\internal\pycore_atomic.h">
       <Filter>Include</Filter>
     </ClInclude>
+    <ClInclude Include="..\Include\internal\pycore_bytes_methods.h">
+      <Filter>Include</Filter>
+    </ClInclude>
     <ClInclude Include="..\Include\internal\pycore_call.h">
       <Filter>Include</Filter>
     </ClInclude>



More information about the Python-checkins mailing list