]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106320: Remove _PyBytes_Join() C API (#107144)
authorVictor Stinner <vstinner@python.org>
Sun, 23 Jul 2023 20:10:12 +0000 (22:10 +0200)
committerGitHub <noreply@github.com>
Sun, 23 Jul 2023 20:10:12 +0000 (20:10 +0000)
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.

Include/cpython/bytesobject.h
Include/internal/pycore_bytesobject.h
Modules/_io/bufferedio.c
Parser/string_parser.c

index 0af4c83b1e5bc7916359782dcf61ebd5085c0c9d..816823716e9a6f5c9bbb785c2d2229fa2b344408 100644 (file)
@@ -15,18 +15,6 @@ typedef struct {
 } PyBytesObject;
 
 PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
-PyAPI_FUNC(PyObject*) _PyBytes_FormatEx(
-    const char *format,
-    Py_ssize_t format_len,
-    PyObject *args,
-    int use_bytearray);
-PyAPI_FUNC(PyObject*) _PyBytes_FromHex(
-    PyObject *string,
-    int use_bytearray);
-
-/* Helper for PyBytes_DecodeEscape that detects invalid escape chars. */
-PyAPI_FUNC(PyObject *) _PyBytes_DecodeEscape(const char *, Py_ssize_t,
-                                             const char *, const char **);
 
 /* Macros and static inline functions, trading safety for speed */
 #define _PyBytes_CAST(op) \
@@ -43,7 +31,3 @@ static inline Py_ssize_t PyBytes_GET_SIZE(PyObject *op) {
     return Py_SIZE(self);
 }
 #define PyBytes_GET_SIZE(self) PyBytes_GET_SIZE(_PyObject_CAST(self))
-
-/* _PyBytes_Join(sep, x) is like sep.join(x).  sep must be PyBytesObject*,
-   x must be an iterable object. */
-PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
index 115c0c52c8f9a9457db259935b26d19431429d68..980065a65f399eee872b5337056d4c6b7102f45d 100644 (file)
@@ -8,6 +8,25 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
+extern PyObject* _PyBytes_FormatEx(
+    const char *format,
+    Py_ssize_t format_len,
+    PyObject *args,
+    int use_bytearray);
+
+extern PyObject* _PyBytes_FromHex(
+    PyObject *string,
+    int use_bytearray);
+
+// Helper for PyBytes_DecodeEscape that detects invalid escape chars.
+// Export for test_peg_generator.
+PyAPI_FUNC(PyObject*) _PyBytes_DecodeEscape(const char *, Py_ssize_t,
+                                            const char *, const char **);
+
+/* _PyBytes_Join(sep, x) is like sep.join(x).  sep must be PyBytesObject*,
+   x must be an iterable object. */
+extern PyObject* _PyBytes_Join(PyObject *sep, PyObject *x);
+
 
 /* Substring Search.
 
index bfc3d2558c9e3640fe30d92bf8d7cad802332103..efc8cb93d88512d3af750f813a33afbed19c64da 100644 (file)
@@ -8,8 +8,9 @@
 */
 
 #include "Python.h"
+#include "pycore_bytesobject.h"   // _PyBytes_Join()
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
-#include "pycore_object.h"
+#include "pycore_object.h"        // _PyObject_GC_UNTRACK()
 #include "pycore_pyerrors.h"      // _Py_FatalErrorFormat()
 #include "pycore_pylifecycle.h"   // _Py_IsInterpreterFinalizing()
 #include "structmember.h"         // PyMemberDef
index bc1f99d607ae4d6c71527c00abc13b862639ae1f..72898c38b79bdef77f0c5e16a31a46ab193c66f1 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdbool.h>
 
 #include <Python.h>
+#include "pycore_bytesobject.h"   // _PyBytes_DecodeEscape()
 #include "pycore_unicodeobject.h" // _PyUnicode_DecodeUnicodeEscapeInternal()
 
 #include "tokenizer.h"