Skip to content

Commit 7d41ead

Browse files
authored
gh-106320: Remove _PyBytes_Join() C API (#107144)
Move private _PyBytes functions to the internal C API (pycore_bytesobject.h): * _PyBytes_DecodeEscape() * _PyBytes_FormatEx() * _PyBytes_FromHex() * _PyBytes_Join() No longer export these functions.
1 parent 0d6dfd6 commit 7d41ead

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

Include/cpython/bytesobject.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,6 @@ typedef struct {
1515
} PyBytesObject;
1616

1717
PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
18-
PyAPI_FUNC(PyObject*) _PyBytes_FormatEx(
19-
const char *format,
20-
Py_ssize_t format_len,
21-
PyObject *args,
22-
int use_bytearray);
23-
PyAPI_FUNC(PyObject*) _PyBytes_FromHex(
24-
PyObject *string,
25-
int use_bytearray);
26-
27-
/* Helper for PyBytes_DecodeEscape that detects invalid escape chars. */
28-
PyAPI_FUNC(PyObject *) _PyBytes_DecodeEscape(const char *, Py_ssize_t,
29-
const char *, const char **);
3018

3119
/* Macros and static inline functions, trading safety for speed */
3220
#define _PyBytes_CAST(op) \
@@ -43,7 +31,3 @@ static inline Py_ssize_t PyBytes_GET_SIZE(PyObject *op) {
4331
return Py_SIZE(self);
4432
}
4533
#define PyBytes_GET_SIZE(self) PyBytes_GET_SIZE(_PyObject_CAST(self))
46-
47-
/* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*,
48-
x must be an iterable object. */
49-
PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);

Include/internal/pycore_bytesobject.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11+
extern PyObject* _PyBytes_FormatEx(
12+
const char *format,
13+
Py_ssize_t format_len,
14+
PyObject *args,
15+
int use_bytearray);
16+
17+
extern PyObject* _PyBytes_FromHex(
18+
PyObject *string,
19+
int use_bytearray);
20+
21+
// Helper for PyBytes_DecodeEscape that detects invalid escape chars.
22+
// Export for test_peg_generator.
23+
PyAPI_FUNC(PyObject*) _PyBytes_DecodeEscape(const char *, Py_ssize_t,
24+
const char *, const char **);
25+
26+
/* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*,
27+
x must be an iterable object. */
28+
extern PyObject* _PyBytes_Join(PyObject *sep, PyObject *x);
29+
1130

1231
/* Substring Search.
1332

Modules/_io/bufferedio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
*/
99

1010
#include "Python.h"
11+
#include "pycore_bytesobject.h" // _PyBytes_Join()
1112
#include "pycore_call.h" // _PyObject_CallNoArgs()
12-
#include "pycore_object.h"
13+
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
1314
#include "pycore_pyerrors.h" // _Py_FatalErrorFormat()
1415
#include "pycore_pylifecycle.h" // _Py_IsInterpreterFinalizing()
1516
#include "structmember.h" // PyMemberDef

Parser/string_parser.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <stdbool.h>
22

33
#include <Python.h>
4+
#include "pycore_bytesobject.h" // _PyBytes_DecodeEscape()
45
#include "pycore_unicodeobject.h" // _PyUnicode_DecodeUnicodeEscapeInternal()
56

67
#include "tokenizer.h"

0 commit comments

Comments
 (0)