Skip to content

Commit

Permalink
Merge branch 'main' into cachedpropdoublecheck
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
carljm committed Jul 4, 2023
2 parents 43ed758 + 3406f8c commit 7a7fd43
Show file tree
Hide file tree
Showing 14 changed files with 647 additions and 481 deletions.
20 changes: 0 additions & 20 deletions Include/cpython/import.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@

PyMODINIT_FUNC PyInit__imp(void);

PyAPI_FUNC(int) _PyImport_IsInitialized(PyInterpreterState *);

PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(_Py_Identifier *name);
PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module);
PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);

PyAPI_FUNC(void) _PyImport_AcquireLock(PyInterpreterState *interp);
PyAPI_FUNC(int) _PyImport_ReleaseLock(PyInterpreterState *interp);

PyAPI_FUNC(int) _PyImport_FixupBuiltin(
PyObject *mod,
const char *name, /* UTF-8 encoded string */
PyObject *modules
);
PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *,
PyObject *, PyObject *);

struct _inittab {
const char *name; /* ASCII encoded string */
PyObject* (*initfunc)(void);
Expand All @@ -41,6 +24,3 @@ struct _frozen {
collection of frozen modules: */

PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules;

PyAPI_DATA(PyObject *) _PyImport_GetModuleAttr(PyObject *, PyObject *);
PyAPI_DATA(PyObject *) _PyImport_GetModuleAttrString(const char *, const char *);
69 changes: 0 additions & 69 deletions Include/cpython/unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,6 @@ static inline int PyUnicode_READY(PyObject* Py_UNUSED(op))
}
#define PyUnicode_READY(op) PyUnicode_READY(_PyObject_CAST(op))

/* Get a copy of a Unicode string. */
PyAPI_FUNC(PyObject*) _PyUnicode_Copy(
PyObject *unicode
);

/* Copy character from one unicode object into another, this function performs
character conversion when necessary and falls back to memcpy() if possible.
Expand All @@ -425,17 +420,6 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_CopyCharacters(
Py_ssize_t how_many
);

/* Unsafe version of PyUnicode_CopyCharacters(): don't check arguments and so
may crash if parameters are invalid (e.g. if the output string
is too short). */
PyAPI_FUNC(void) _PyUnicode_FastCopyCharacters(
PyObject *to,
Py_ssize_t to_start,
PyObject *from,
Py_ssize_t from_start,
Py_ssize_t how_many
);

/* Fill a string with a character: write fill_char into
unicode[start:start+length].
Expand All @@ -451,35 +435,13 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_Fill(
Py_UCS4 fill_char
);

/* Unsafe version of PyUnicode_Fill(): don't check arguments and so may crash
if parameters are invalid (e.g. if length is longer than the string). */
PyAPI_FUNC(void) _PyUnicode_FastFill(
PyObject *unicode,
Py_ssize_t start,
Py_ssize_t length,
Py_UCS4 fill_char
);

/* Create a new string from a buffer of Py_UCS1, Py_UCS2 or Py_UCS4 characters.
Scan the string to find the maximum character. */
PyAPI_FUNC(PyObject*) PyUnicode_FromKindAndData(
int kind,
const void *buffer,
Py_ssize_t size);

/* Create a new string from a buffer of ASCII characters.
WARNING: Don't check if the string contains any non-ASCII character. */
PyAPI_FUNC(PyObject*) _PyUnicode_FromASCII(
const char *buffer,
Py_ssize_t size);

/* Compute the maximum character of the substring unicode[start:end].
Return 127 for an empty string. */
PyAPI_FUNC(Py_UCS4) _PyUnicode_FindMaxChar (
PyObject *unicode,
Py_ssize_t start,
Py_ssize_t end);

/* --- Manage the default encoding ---------------------------------------- */

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

/* --- Methods & Slots ---------------------------------------------------- */

PyAPI_FUNC(PyObject *) _PyUnicode_JoinArray(
PyObject *separator,
PyObject *const *items,
Py_ssize_t seqlen
);

/* Test whether a unicode is equal to ASCII identifier. Return 1 if true,
0 otherwise. The right argument must be ASCII identifier.
Any error occurs inside will be cleared before return. */
PyAPI_FUNC(int) _PyUnicode_EqualToASCIIId(
PyObject *left, /* Left string */
_Py_Identifier *right /* Right identifier */
);

/* Test whether a unicode is equal to ASCII string. Return 1 if true,
0 otherwise. The right argument must be ASCII-encoded string.
Any error occurs inside will be cleared before return. */
PyAPI_FUNC(int) _PyUnicode_EqualToASCIIString(
PyObject *left,
const char *right /* ASCII-encoded string */
);

/* Externally visible for str.strip(unicode) */
PyAPI_FUNC(PyObject *) _PyUnicode_XStrip(
PyObject *self,
int striptype,
PyObject *sepobj
);

/* === Characters Type APIs =============================================== */

/* These should not be used directly. Use the Py_UNICODE_IS* and
Expand Down
2 changes: 0 additions & 2 deletions Include/internal/pycore_codecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ extern "C" {

extern PyObject* _PyCodec_Lookup(const char *encoding);

extern int _PyCodec_Forget(const char *encoding);

/* Text codec specific encoding and decoding API.
Checks the encoding against a list of codecs which do not
Expand Down
20 changes: 20 additions & 0 deletions Include/internal/pycore_import.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ extern "C" {

#include "pycore_time.h" // _PyTime_t

extern int _PyImport_IsInitialized(PyInterpreterState *);

PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(_Py_Identifier *name);
PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module);
PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);

extern void _PyImport_AcquireLock(PyInterpreterState *interp);
extern int _PyImport_ReleaseLock(PyInterpreterState *interp);

extern int _PyImport_FixupBuiltin(
PyObject *mod,
const char *name, /* UTF-8 encoded string */
PyObject *modules
);
extern int _PyImport_FixupExtensionObject(PyObject*, PyObject *,
PyObject *, PyObject *);

PyAPI_FUNC(PyObject *) _PyImport_GetModuleAttr(PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) _PyImport_GetModuleAttrString(const char *, const char *);


struct _import_runtime_state {
/* The builtin modules (defined in config.c). */
Expand Down
70 changes: 69 additions & 1 deletion Include/internal/pycore_unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,44 @@ extern "C" {
void _PyUnicode_ExactDealloc(PyObject *op);
Py_ssize_t _PyUnicode_InternedSize(void);

/* Get a copy of a Unicode string. */
PyAPI_FUNC(PyObject*) _PyUnicode_Copy(
PyObject *unicode
);

/* Unsafe version of PyUnicode_Fill(): don't check arguments and so may crash
if parameters are invalid (e.g. if length is longer than the string). */
extern void _PyUnicode_FastFill(
PyObject *unicode,
Py_ssize_t start,
Py_ssize_t length,
Py_UCS4 fill_char
);

/* Unsafe version of PyUnicode_CopyCharacters(): don't check arguments and so
may crash if parameters are invalid (e.g. if the output string
is too short). */
extern void _PyUnicode_FastCopyCharacters(
PyObject *to,
Py_ssize_t to_start,
PyObject *from,
Py_ssize_t from_start,
Py_ssize_t how_many
);

/* Create a new string from a buffer of ASCII characters.
WARNING: Don't check if the string contains any non-ASCII character. */
extern PyObject* _PyUnicode_FromASCII(
const char *buffer,
Py_ssize_t size);

/* Compute the maximum character of the substring unicode[start:end].
Return 127 for an empty string. */
extern Py_UCS4 _PyUnicode_FindMaxChar (
PyObject *unicode,
Py_ssize_t start,
Py_ssize_t end);

/* --- _PyUnicodeWriter API ----------------------------------------------- */

typedef struct {
Expand Down Expand Up @@ -141,10 +179,40 @@ PyAPI_FUNC(int) _PyUnicode_FormatAdvancedWriter(

/* --- Methods & Slots ---------------------------------------------------- */

extern PyObject* _PyUnicode_JoinArray(
PyObject *separator,
PyObject *const *items,
Py_ssize_t seqlen
);

/* Test whether a unicode is equal to ASCII identifier. Return 1 if true,
0 otherwise. The right argument must be ASCII identifier.
Any error occurs inside will be cleared before return. */
extern int _PyUnicode_EqualToASCIIId(
PyObject *left, /* Left string */
_Py_Identifier *right /* Right identifier */
);

/* Test whether a unicode is equal to ASCII string. Return 1 if true,
0 otherwise. The right argument must be ASCII-encoded string.
Any error occurs inside will be cleared before return. */
PyAPI_FUNC(int) _PyUnicode_EqualToASCIIString(
PyObject *left,
const char *right /* ASCII-encoded string */
);

/* Externally visible for str.strip(unicode) */
extern PyObject* _PyUnicode_XStrip(
PyObject *self,
int striptype,
PyObject *sepobj
);


/* Using explicit passed-in values, insert the thousands grouping
into the string pointed to by buffer. For the argument descriptions,
see Objects/stringlib/localeutil.h */
PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGrouping(
extern Py_ssize_t _PyUnicode_InsertThousandsGrouping(
_PyUnicodeWriter *writer,
Py_ssize_t n_buffer,
PyObject *digits,
Expand Down
Loading

0 comments on commit 7a7fd43

Please sign in to comment.