Skip to content

Commit 45876a9

Browse files
authored
bpo-35081: Move bytes_methods.h to the internal C API (pythonGH-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.
1 parent 6e619c4 commit 45876a9

10 files changed

+17
-10
lines changed

Include/bytes_methods.h Include/internal/pycore_bytes_methods.h

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#ifndef Py_BYTES_CTYPE_H
33
#define Py_BYTES_CTYPE_H
44

5+
#ifndef Py_BUILD_CORE
6+
# error "this header requires Py_BUILD_CORE define"
7+
#endif
8+
59
/*
610
* The internal implementation behind PyBytes (bytes) and PyByteArray (bytearray)
711
* methods of the given names, they operate on ASCII byte strings.

Makefile.pre.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,6 @@ PYTHON_HEADERS= \
970970
$(srcdir)/Include/bltinmodule.h \
971971
$(srcdir)/Include/boolobject.h \
972972
$(srcdir)/Include/bytearrayobject.h \
973-
$(srcdir)/Include/bytes_methods.h \
974973
$(srcdir)/Include/bytesobject.h \
975974
$(srcdir)/Include/cellobject.h \
976975
$(srcdir)/Include/ceval.h \
@@ -1077,6 +1076,7 @@ PYTHON_HEADERS= \
10771076
\
10781077
$(srcdir)/Include/internal/pycore_accu.h \
10791078
$(srcdir)/Include/internal/pycore_atomic.h \
1079+
$(srcdir)/Include/internal/pycore_bytes_methods.h \
10801080
$(srcdir)/Include/internal/pycore_call.h \
10811081
$(srcdir)/Include/internal/pycore_ceval.h \
10821082
$(srcdir)/Include/internal/pycore_code.h \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Move the ``bytes_methods.h`` header file to the internal C API as
2+
``pycore_bytes_methods.h``: it only contains private symbols (prefixed by
3+
``_Py``), except of the ``PyDoc_STRVAR_shared()`` macro.

Objects/bytearrayobject.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
#define PY_SSIZE_T_CLEAN
44
#include "Python.h"
5+
#include "pycore_bytes_methods.h"
56
#include "pycore_object.h"
67
#include "pycore_pymem.h"
78
#include "pycore_pystate.h"
89
#include "structmember.h"
9-
#include "bytes_methods.h"
1010
#include "bytesobject.h"
1111
#include "pystrhex.h"
1212

Objects/bytes_methods.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define PY_SSIZE_T_CLEAN
22
#include "Python.h"
3-
#include "bytes_methods.h"
3+
#include "pycore_bytes_methods.h"
44

55
PyDoc_STRVAR_shared(_Py_isspace__doc__,
66
"B.isspace() -> bool\n\

Objects/bytesobject.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
#define PY_SSIZE_T_CLEAN
44

55
#include "Python.h"
6+
#include "pycore_bytes_methods.h"
67
#include "pycore_object.h"
78
#include "pycore_pymem.h"
89
#include "pycore_pystate.h"
910

10-
#include "bytes_methods.h"
1111
#include "pystrhex.h"
1212
#include <stddef.h>
1313

Objects/stringlib/ctype.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# error "ctype.h only compatible with byte-wise strings"
33
#endif
44

5-
#include "bytes_methods.h"
5+
#include "pycore_bytes_methods.h"
66

77
static PyObject*
88
stringlib_isspace(PyObject *self, PyObject *Py_UNUSED(ignored))

Objects/unicodeobject.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4040

4141
#define PY_SSIZE_T_CLEAN
4242
#include "Python.h"
43+
#include "pycore_bytes_methods.h"
4344
#include "pycore_fileutils.h"
4445
#include "pycore_initconfig.h"
4546
#include "pycore_object.h"
4647
#include "pycore_pathconfig.h"
4748
#include "pycore_pylifecycle.h"
4849
#include "pycore_pystate.h"
4950
#include "ucnhash.h"
50-
#include "bytes_methods.h"
5151
#include "stringlib/eq.h"
5252

5353
#ifdef MS_WINDOWS

PCbuild/pythoncore.vcxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
<ClInclude Include="..\Include\ast.h" />
116116
<ClInclude Include="..\Include\bitset.h" />
117117
<ClInclude Include="..\Include\boolobject.h" />
118-
<ClInclude Include="..\Include\bytes_methods.h" />
119118
<ClInclude Include="..\Include\bytearrayobject.h" />
120119
<ClInclude Include="..\Include\bytesobject.h" />
121120
<ClInclude Include="..\Include\cellobject.h" />
@@ -161,6 +160,7 @@
161160
<ClInclude Include="..\Include\import.h" />
162161
<ClInclude Include="..\Include\internal\pycore_accu.h" />
163162
<ClInclude Include="..\Include\internal\pycore_atomic.h" />
163+
<ClInclude Include="..\Include\internal\pycore_bytes_methods.h" />
164164
<ClInclude Include="..\Include\internal\pycore_call.h" />
165165
<ClInclude Include="..\Include\internal\pycore_ceval.h" />
166166
<ClInclude Include="..\Include\internal\pycore_code.h" />

PCbuild/pythoncore.vcxproj.filters

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@
4848
<ClInclude Include="..\Include\boolobject.h">
4949
<Filter>Include</Filter>
5050
</ClInclude>
51-
<ClInclude Include="..\Include\bytes_methods.h">
52-
<Filter>Include</Filter>
53-
</ClInclude>
5451
<ClInclude Include="..\Include\bytearrayobject.h">
5552
<Filter>Include</Filter>
5653
</ClInclude>
@@ -186,6 +183,9 @@
186183
<ClInclude Include="..\Include\internal\pycore_atomic.h">
187184
<Filter>Include</Filter>
188185
</ClInclude>
186+
<ClInclude Include="..\Include\internal\pycore_bytes_methods.h">
187+
<Filter>Include</Filter>
188+
</ClInclude>
189189
<ClInclude Include="..\Include\internal\pycore_call.h">
190190
<Filter>Include</Filter>
191191
</ClInclude>

0 commit comments

Comments
 (0)