Skip to content

Commit 7a7fd43

Browse files
committed
Merge branch 'main' into cachedpropdoublecheck
* main: pythongh-106368: Increase Argument Clinic test coverage (python#106389) pythongh-106320: Fix _PyImport_GetModuleAttr() declaration (python#106386) pythongh-106368: Harden Argument Clinic parser tests (python#106384) pythongh-106320: Remove private _PyImport C API functions (python#106383) pythongh-86085: Remove _PyCodec_Forget() declaration (python#106377) pythongh-106320: Remove more private _PyUnicode C API functions (python#106382) pythongh-104050: Annotate more Argument Clinic DSLParser state methods (python#106376) pythongh-106368: Clean up Argument Clinic tests (python#106373)
2 parents 43ed758 + 3406f8c commit 7a7fd43

File tree

14 files changed

+647
-481
lines changed

14 files changed

+647
-481
lines changed

Include/cpython/import.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,6 @@
44

55
PyMODINIT_FUNC PyInit__imp(void);
66

7-
PyAPI_FUNC(int) _PyImport_IsInitialized(PyInterpreterState *);
8-
9-
PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(_Py_Identifier *name);
10-
PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module);
11-
PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);
12-
13-
PyAPI_FUNC(void) _PyImport_AcquireLock(PyInterpreterState *interp);
14-
PyAPI_FUNC(int) _PyImport_ReleaseLock(PyInterpreterState *interp);
15-
16-
PyAPI_FUNC(int) _PyImport_FixupBuiltin(
17-
PyObject *mod,
18-
const char *name, /* UTF-8 encoded string */
19-
PyObject *modules
20-
);
21-
PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *,
22-
PyObject *, PyObject *);
23-
247
struct _inittab {
258
const char *name; /* ASCII encoded string */
269
PyObject* (*initfunc)(void);
@@ -41,6 +24,3 @@ struct _frozen {
4124
collection of frozen modules: */
4225

4326
PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules;
44-
45-
PyAPI_DATA(PyObject *) _PyImport_GetModuleAttr(PyObject *, PyObject *);
46-
PyAPI_DATA(PyObject *) _PyImport_GetModuleAttrString(const char *, const char *);

Include/cpython/unicodeobject.h

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,6 @@ static inline int PyUnicode_READY(PyObject* Py_UNUSED(op))
394394
}
395395
#define PyUnicode_READY(op) PyUnicode_READY(_PyObject_CAST(op))
396396

397-
/* Get a copy of a Unicode string. */
398-
PyAPI_FUNC(PyObject*) _PyUnicode_Copy(
399-
PyObject *unicode
400-
);
401-
402397
/* Copy character from one unicode object into another, this function performs
403398
character conversion when necessary and falls back to memcpy() if possible.
404399
@@ -425,17 +420,6 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_CopyCharacters(
425420
Py_ssize_t how_many
426421
);
427422

428-
/* Unsafe version of PyUnicode_CopyCharacters(): don't check arguments and so
429-
may crash if parameters are invalid (e.g. if the output string
430-
is too short). */
431-
PyAPI_FUNC(void) _PyUnicode_FastCopyCharacters(
432-
PyObject *to,
433-
Py_ssize_t to_start,
434-
PyObject *from,
435-
Py_ssize_t from_start,
436-
Py_ssize_t how_many
437-
);
438-
439423
/* Fill a string with a character: write fill_char into
440424
unicode[start:start+length].
441425
@@ -451,35 +435,13 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_Fill(
451435
Py_UCS4 fill_char
452436
);
453437

454-
/* Unsafe version of PyUnicode_Fill(): don't check arguments and so may crash
455-
if parameters are invalid (e.g. if length is longer than the string). */
456-
PyAPI_FUNC(void) _PyUnicode_FastFill(
457-
PyObject *unicode,
458-
Py_ssize_t start,
459-
Py_ssize_t length,
460-
Py_UCS4 fill_char
461-
);
462-
463438
/* Create a new string from a buffer of Py_UCS1, Py_UCS2 or Py_UCS4 characters.
464439
Scan the string to find the maximum character. */
465440
PyAPI_FUNC(PyObject*) PyUnicode_FromKindAndData(
466441
int kind,
467442
const void *buffer,
468443
Py_ssize_t size);
469444

470-
/* Create a new string from a buffer of ASCII characters.
471-
WARNING: Don't check if the string contains any non-ASCII character. */
472-
PyAPI_FUNC(PyObject*) _PyUnicode_FromASCII(
473-
const char *buffer,
474-
Py_ssize_t size);
475-
476-
/* Compute the maximum character of the substring unicode[start:end].
477-
Return 127 for an empty string. */
478-
PyAPI_FUNC(Py_UCS4) _PyUnicode_FindMaxChar (
479-
PyObject *unicode,
480-
Py_ssize_t start,
481-
Py_ssize_t end);
482-
483445
/* --- Manage the default encoding ---------------------------------------- */
484446

485447
/* Returns a pointer to the default encoding (UTF-8) of the
@@ -618,37 +580,6 @@ PyAPI_FUNC(PyObject*) _PyUnicode_TransformDecimalAndSpaceToASCII(
618580
PyObject *unicode /* Unicode object */
619581
);
620582

621-
/* --- Methods & Slots ---------------------------------------------------- */
622-
623-
PyAPI_FUNC(PyObject *) _PyUnicode_JoinArray(
624-
PyObject *separator,
625-
PyObject *const *items,
626-
Py_ssize_t seqlen
627-
);
628-
629-
/* Test whether a unicode is equal to ASCII identifier. Return 1 if true,
630-
0 otherwise. The right argument must be ASCII identifier.
631-
Any error occurs inside will be cleared before return. */
632-
PyAPI_FUNC(int) _PyUnicode_EqualToASCIIId(
633-
PyObject *left, /* Left string */
634-
_Py_Identifier *right /* Right identifier */
635-
);
636-
637-
/* Test whether a unicode is equal to ASCII string. Return 1 if true,
638-
0 otherwise. The right argument must be ASCII-encoded string.
639-
Any error occurs inside will be cleared before return. */
640-
PyAPI_FUNC(int) _PyUnicode_EqualToASCIIString(
641-
PyObject *left,
642-
const char *right /* ASCII-encoded string */
643-
);
644-
645-
/* Externally visible for str.strip(unicode) */
646-
PyAPI_FUNC(PyObject *) _PyUnicode_XStrip(
647-
PyObject *self,
648-
int striptype,
649-
PyObject *sepobj
650-
);
651-
652583
/* === Characters Type APIs =============================================== */
653584

654585
/* These should not be used directly. Use the Py_UNICODE_IS* and

Include/internal/pycore_codecs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ extern "C" {
66

77
extern PyObject* _PyCodec_Lookup(const char *encoding);
88

9-
extern int _PyCodec_Forget(const char *encoding);
10-
119
/* Text codec specific encoding and decoding API.
1210
1311
Checks the encoding against a list of codecs which do not

Include/internal/pycore_import.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,26 @@ extern "C" {
77

88
#include "pycore_time.h" // _PyTime_t
99

10+
extern int _PyImport_IsInitialized(PyInterpreterState *);
11+
12+
PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(_Py_Identifier *name);
13+
PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module);
14+
PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);
15+
16+
extern void _PyImport_AcquireLock(PyInterpreterState *interp);
17+
extern int _PyImport_ReleaseLock(PyInterpreterState *interp);
18+
19+
extern int _PyImport_FixupBuiltin(
20+
PyObject *mod,
21+
const char *name, /* UTF-8 encoded string */
22+
PyObject *modules
23+
);
24+
extern int _PyImport_FixupExtensionObject(PyObject*, PyObject *,
25+
PyObject *, PyObject *);
26+
27+
PyAPI_FUNC(PyObject *) _PyImport_GetModuleAttr(PyObject *, PyObject *);
28+
PyAPI_FUNC(PyObject *) _PyImport_GetModuleAttrString(const char *, const char *);
29+
1030

1131
struct _import_runtime_state {
1232
/* The builtin modules (defined in config.c). */

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,

0 commit comments

Comments
 (0)