gh-106320: Remove more private _PyUnicode C API functions (#106382) · python/cpython@506cfdf · GitHub
Skip to content

Commit 506cfdf

Browse files
authored
gh-106320: Remove more private _PyUnicode C API functions (#106382)
Remove more private _PyUnicode C API functions: move them to the internal C API (pycore_unicodeobject.h). No longer export most pycore_unicodeobject.h functions.
1 parent b24479d commit 506cfdf

3 files changed

Lines changed: 70 additions & 70 deletions

File tree

Include/cpython/unicodeobject.h

Lines changed: 0 additions & 69 deletions

Include/internal/pycore_unicodeobject.h

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,44 @@ extern "C" {
1414
void _PyUnicode_ExactDealloc(PyObject *op);
1515
Py_ssize_t _PyUnicode_InternedSize(void);
1616

17+
/* Get a copy of a Unicode string. */
18+
PyAPI_FUNC(PyObject*) _PyUnicode_Copy(
19+
PyObject *unicode
20+
);
21+
22+
/* Unsafe version of PyUnicode_Fill(): don't check arguments and so may crash
23+
if parameters are invalid (e.g. if length is longer than the string). */
24+
extern void _PyUnicode_FastFill(
25+
PyObject *unicode,
26+
Py_ssize_t start,
27+
Py_ssize_t length,
28+
Py_UCS4 fill_char
29+
);
30+
31+
/* Unsafe version of PyUnicode_CopyCharacters(): don't check arguments and so
32+
may crash if parameters are invalid (e.g. if the output string
33+
is too short). */
34+
extern void _PyUnicode_FastCopyCharacters(
35+
PyObject *to,
36+
Py_ssize_t to_start,
37+
PyObject *from,
38+
Py_ssize_t from_start,
39+
Py_ssize_t how_many
40+
);
41+
42+
/* Create a new string from a buffer of ASCII characters.
43+
WARNING: Don't check if the string contains any non-ASCII character. */
44+
extern PyObject* _PyUnicode_FromASCII(
45+
const char *buffer,
46+
Py_ssize_t size);
47+
48+
/* Compute the maximum character of the substring unicode[start:end].
49+
Return 127 for an empty string. */
50+
extern Py_UCS4 _PyUnicode_FindMaxChar (
51+
PyObject *unicode,
52+
Py_ssize_t start,
53+
Py_ssize_t end);
54+
1755
/* --- _PyUnicodeWriter API ----------------------------------------------- */
1856

1957
typedef struct {
@@ -141,10 +179,40 @@ PyAPI_FUNC(int) _PyUnicode_FormatAdvancedWriter(
141179

142180
/* --- Methods & Slots ---------------------------------------------------- */
143181

182+
extern PyObject* _PyUnicode_JoinArray(
183+
PyObject *separator,
184+
PyObject *const *items,
185+
Py_ssize_t seqlen
186+
);
187+
188+
/* Test whether a unicode is equal to ASCII identifier. Return 1 if true,
189+
0 otherwise. The right argument must be ASCII identifier.
190+
Any error occurs inside will be cleared before return. */
191+
extern int _PyUnicode_EqualToASCIIId(
192+
PyObject *left, /* Left string */
193+
_Py_Identifier *right /* Right identifier */
194+
);
195+
196+
/* Test whether a unicode is equal to ASCII string. Return 1 if true,
197+
0 otherwise. The right argument must be ASCII-encoded string.
198+
Any error occurs inside will be cleared before return. */
199+
PyAPI_FUNC(int) _PyUnicode_EqualToASCIIString(
200+
PyObject *left,
201+
const char *right /* ASCII-encoded string */
202+
);
203+
204+
/* Externally visible for str.strip(unicode) */
205+
extern PyObject* _PyUnicode_XStrip(
206+
PyObject *self,
207+
int striptype,
208+
PyObject *sepobj
209+
);
210+
211+
144212
/* Using explicit passed-in values, insert the thousands grouping
145213
into the string pointed to by buffer. For the argument descriptions,
146214
see Objects/stringlib/localeutil.h */
147-
PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGrouping(
215+
extern Py_ssize_t _PyUnicode_InsertThousandsGrouping(
148216
_PyUnicodeWriter *writer,
149217
Py_ssize_t n_buffer,
150218
PyObject *digits,

Python/future.c

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)