Skip to content

Commit 00525f0

Browse files
committed
Merge remote-tracking branch 'origin/main' into jump-uops
2 parents 8681e0c + 17af982 commit 00525f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+696
-392
lines changed

.github/CODEOWNERS

+4
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,7 @@ Doc/c-api/stable.rst @encukou
173173

174174
# zipfile.Path
175175
**/*zipfile/*_path.py @jaraco
176+
177+
# Argument Clinic
178+
/Tools/clinic/** @erlend-aasland @AlexWaygood
179+
/Lib/test/test_clinic.py @erlend-aasland @AlexWaygood

.github/workflows/new-bugs-announce-notifier.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
// We need to truncate the body size, because the max size for
4545
// the whole payload is 16kb. We want to be safe and assume that
4646
// body can take up to ~8kb of space.
47-
body : issue.data.body.substring(8000)
47+
body : issue.data.body.substring(0, 8000)
4848
};
4949
5050
const data = {

Doc/library/unittest.mock.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ object::
11261126
>>> mock.wait_until_called(timeout=1)
11271127
>>> thread.join()
11281128

1129-
.. method:: wait_until_any_call(*args, **kwargs)
1129+
.. method:: wait_until_any_call_with(*args, **kwargs)
11301130

11311131
Waits until the the mock is called with the specified arguments.
11321132

@@ -1136,7 +1136,7 @@ object::
11361136
>>> mock = ThreadingMock()
11371137
>>> thread = threading.Thread(target=mock, args=("arg1", "arg2",), kwargs={"arg": "thing"})
11381138
>>> thread.start()
1139-
>>> mock.wait_until_any_call("arg1", "arg2", arg="thing")
1139+
>>> mock.wait_until_any_call_with("arg1", "arg2", arg="thing")
11401140
>>> thread.join()
11411141

11421142
.. attribute:: DEFAULT_TIMEOUT

Include/cpython/bytesobject.h

-80
Original file line numberDiff line numberDiff line change
@@ -47,83 +47,3 @@ static inline Py_ssize_t PyBytes_GET_SIZE(PyObject *op) {
4747
/* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*,
4848
x must be an iterable object. */
4949
PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
50-
51-
52-
/* The _PyBytesWriter structure is big: it contains an embedded "stack buffer".
53-
A _PyBytesWriter variable must be declared at the end of variables in a
54-
function to optimize the memory allocation on the stack. */
55-
typedef struct {
56-
/* bytes, bytearray or NULL (when the small buffer is used) */
57-
PyObject *buffer;
58-
59-
/* Number of allocated size. */
60-
Py_ssize_t allocated;
61-
62-
/* Minimum number of allocated bytes,
63-
incremented by _PyBytesWriter_Prepare() */
64-
Py_ssize_t min_size;
65-
66-
/* If non-zero, use a bytearray instead of a bytes object for buffer. */
67-
int use_bytearray;
68-
69-
/* If non-zero, overallocate the buffer (default: 0).
70-
This flag must be zero if use_bytearray is non-zero. */
71-
int overallocate;
72-
73-
/* Stack buffer */
74-
int use_small_buffer;
75-
char small_buffer[512];
76-
} _PyBytesWriter;
77-
78-
/* Initialize a bytes writer
79-
80-
By default, the overallocation is disabled. Set the overallocate attribute
81-
to control the allocation of the buffer. */
82-
PyAPI_FUNC(void) _PyBytesWriter_Init(_PyBytesWriter *writer);
83-
84-
/* Get the buffer content and reset the writer.
85-
Return a bytes object, or a bytearray object if use_bytearray is non-zero.
86-
Raise an exception and return NULL on error. */
87-
PyAPI_FUNC(PyObject *) _PyBytesWriter_Finish(_PyBytesWriter *writer,
88-
void *str);
89-
90-
/* Deallocate memory of a writer (clear its internal buffer). */
91-
PyAPI_FUNC(void) _PyBytesWriter_Dealloc(_PyBytesWriter *writer);
92-
93-
/* Allocate the buffer to write size bytes.
94-
Return the pointer to the beginning of buffer data.
95-
Raise an exception and return NULL on error. */
96-
PyAPI_FUNC(void*) _PyBytesWriter_Alloc(_PyBytesWriter *writer,
97-
Py_ssize_t size);
98-
99-
/* Ensure that the buffer is large enough to write *size* bytes.
100-
Add size to the writer minimum size (min_size attribute).
101-
102-
str is the current pointer inside the buffer.
103-
Return the updated current pointer inside the buffer.
104-
Raise an exception and return NULL on error. */
105-
PyAPI_FUNC(void*) _PyBytesWriter_Prepare(_PyBytesWriter *writer,
106-
void *str,
107-
Py_ssize_t size);
108-
109-
/* Resize the buffer to make it larger.
110-
The new buffer may be larger than size bytes because of overallocation.
111-
Return the updated current pointer inside the buffer.
112-
Raise an exception and return NULL on error.
113-
114-
Note: size must be greater than the number of allocated bytes in the writer.
115-
116-
This function doesn't use the writer minimum size (min_size attribute).
117-
118-
See also _PyBytesWriter_Prepare().
119-
*/
120-
PyAPI_FUNC(void*) _PyBytesWriter_Resize(_PyBytesWriter *writer,
121-
void *str,
122-
Py_ssize_t size);
123-
124-
/* Write bytes.
125-
Raise an exception and return NULL on error. */
126-
PyAPI_FUNC(void*) _PyBytesWriter_WriteBytes(_PyBytesWriter *writer,
127-
void *str,
128-
const void *bytes,
129-
Py_ssize_t size);

Include/cpython/optimizer.h

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ PyAPI_FUNC(void) PyUnstable_SetOptimizer(_PyOptimizerObject* optimizer);
3838

3939
PyAPI_FUNC(_PyOptimizerObject *) PyUnstable_GetOptimizer(void);
4040

41+
PyAPI_FUNC(_PyExecutorObject *)PyUnstable_GetExecutor(PyCodeObject *code, int offset);
42+
4143
struct _PyInterpreterFrame *
4244
_PyOptimizer_BackEdge(struct _PyInterpreterFrame *frame, _Py_CODEUNIT *src, _Py_CODEUNIT *dest, PyObject **stack_pointer);
4345

Include/cpython/pylifecycle.h

+2-25
Original file line numberDiff line numberDiff line change
@@ -19,45 +19,22 @@ PyAPI_FUNC(PyStatus) Py_PreInitializeFromArgs(
1919
Py_ssize_t argc,
2020
wchar_t **argv);
2121

22-
PyAPI_FUNC(int) _Py_IsCoreInitialized(void);
23-
2422

2523
/* Initialization and finalization */
2624

2725
PyAPI_FUNC(PyStatus) Py_InitializeFromConfig(
2826
const PyConfig *config);
27+
28+
// Python 3.8 provisional API (PEP 587)
2929
PyAPI_FUNC(PyStatus) _Py_InitializeMain(void);
3030

3131
PyAPI_FUNC(int) Py_RunMain(void);
3232

3333

3434
PyAPI_FUNC(void) _Py_NO_RETURN Py_ExitStatusException(PyStatus err);
3535

36-
/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
37-
PyAPI_FUNC(void) _Py_RestoreSignals(void);
38-
3936
PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
40-
PyAPI_FUNC(int) _Py_FdIsInteractive(FILE *fp, PyObject *filename);
41-
42-
PyAPI_FUNC(const char *) _Py_gitidentifier(void);
43-
PyAPI_FUNC(const char *) _Py_gitversion(void);
44-
45-
PyAPI_FUNC(int) _Py_IsFinalizing(void);
46-
PyAPI_FUNC(int) _Py_IsInterpreterFinalizing(PyInterpreterState *interp);
47-
48-
/* Random */
49-
PyAPI_FUNC(int) _PyOS_URandom(void *buffer, Py_ssize_t size);
50-
PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size);
51-
52-
/* Legacy locale support */
53-
PyAPI_FUNC(int) _Py_CoerceLegacyLocale(int warn);
54-
PyAPI_FUNC(int) _Py_LegacyLocaleDetected(int warn);
55-
PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category);
5637

5738
PyAPI_FUNC(PyStatus) Py_NewInterpreterFromConfig(
5839
PyThreadState **tstate_p,
5940
const PyInterpreterConfig *config);
60-
61-
typedef void (*atexit_datacallbackfunc)(void *);
62-
PyAPI_FUNC(int) _Py_AtExit(
63-
PyInterpreterState *, atexit_datacallbackfunc, void *);

Include/cpython/pystate.h

-32
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,6 @@
33
#endif
44

55

6-
/*
7-
Runtime Feature Flags
8-
9-
Each flag indicate whether or not a specific runtime feature
10-
is available in a given context. For example, forking the process
11-
might not be allowed in the current interpreter (i.e. os.fork() would fail).
12-
*/
13-
14-
/* Set if the interpreter share obmalloc runtime state
15-
with the main interpreter. */
16-
#define Py_RTFLAGS_USE_MAIN_OBMALLOC (1UL << 5)
17-
18-
/* Set if import should check a module for subinterpreter support. */
19-
#define Py_RTFLAGS_MULTI_INTERP_EXTENSIONS (1UL << 8)
20-
21-
/* Set if threads are allowed. */
22-
#define Py_RTFLAGS_THREADS (1UL << 10)
23-
24-
/* Set if daemon threads are allowed. */
25-
#define Py_RTFLAGS_DAEMON_THREADS (1UL << 11)
26-
27-
/* Set if os.fork() is allowed. */
28-
#define Py_RTFLAGS_FORK (1UL << 15)
29-
30-
/* Set if os.exec*() is allowed. */
31-
#define Py_RTFLAGS_EXEC (1UL << 16)
32-
33-
34-
PyAPI_FUNC(int) _PyInterpreterState_HasFeature(PyInterpreterState *interp,
35-
unsigned long feature);
36-
37-
386
/* private interpreter helpers */
397

408
PyAPI_FUNC(int) _PyInterpreterState_RequiresIDRef(PyInterpreterState *);

Include/cpython/unicodeobject.h

-143
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ typedef struct {
167167
} data; /* Canonical, smallest-form Unicode buffer */
168168
} PyUnicodeObject;
169169

170-
PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
171-
PyObject *op,
172-
int check_content);
173-
174170

175171
#define _PyASCIIObject_CAST(op) \
176172
(assert(PyUnicode_Check(op)), \
@@ -461,125 +457,6 @@ PyAPI_FUNC(const char *) PyUnicode_AsUTF8(PyObject *unicode);
461457

462458
#define _PyUnicode_AsString PyUnicode_AsUTF8
463459

464-
/* --- UTF-7 Codecs ------------------------------------------------------- */
465-
466-
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF7(
467-
PyObject *unicode, /* Unicode object */
468-
int base64SetO, /* Encode RFC2152 Set O characters in base64 */
469-
int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */
470-
const char *errors /* error handling */
471-
);
472-
473-
/* --- UTF-8 Codecs ------------------------------------------------------- */
474-
475-
PyAPI_FUNC(PyObject*) _PyUnicode_AsUTF8String(
476-
PyObject *unicode,
477-
const char *errors);
478-
479-
/* --- UTF-32 Codecs ------------------------------------------------------ */
480-
481-
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF32(
482-
PyObject *object, /* Unicode object */
483-
const char *errors, /* error handling */
484-
int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
485-
);
486-
487-
/* --- UTF-16 Codecs ------------------------------------------------------ */
488-
489-
/* Returns a Python string object holding the UTF-16 encoded value of
490-
the Unicode data.
491-
492-
If byteorder is not 0, output is written according to the following
493-
byte order:
494-
495-
byteorder == -1: little endian
496-
byteorder == 0: native byte order (writes a BOM mark)
497-
byteorder == 1: big endian
498-
499-
If byteorder is 0, the output string will always start with the
500-
Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is
501-
prepended.
502-
*/
503-
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF16(
504-
PyObject* unicode, /* Unicode object */
505-
const char *errors, /* error handling */
506-
int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
507-
);
508-
509-
/* --- Unicode-Escape Codecs ---------------------------------------------- */
510-
511-
/* Variant of PyUnicode_DecodeUnicodeEscape that supports partial decoding. */
512-
PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeStateful(
513-
const char *string, /* Unicode-Escape encoded string */
514-
Py_ssize_t length, /* size of string */
515-
const char *errors, /* error handling */
516-
Py_ssize_t *consumed /* bytes consumed */
517-
);
518-
/* Helper for PyUnicode_DecodeUnicodeEscape that detects invalid escape
519-
chars. */
520-
PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeInternal(
521-
const char *string, /* Unicode-Escape encoded string */
522-
Py_ssize_t length, /* size of string */
523-
const char *errors, /* error handling */
524-
Py_ssize_t *consumed, /* bytes consumed */
525-
const char **first_invalid_escape /* on return, points to first
526-
invalid escaped char in
527-
string. */
528-
);
529-
530-
/* --- Raw-Unicode-Escape Codecs ---------------------------------------------- */
531-
532-
/* Variant of PyUnicode_DecodeRawUnicodeEscape that supports partial decoding. */
533-
PyAPI_FUNC(PyObject*) _PyUnicode_DecodeRawUnicodeEscapeStateful(
534-
const char *string, /* Unicode-Escape encoded string */
535-
Py_ssize_t length, /* size of string */
536-
const char *errors, /* error handling */
537-
Py_ssize_t *consumed /* bytes consumed */
538-
);
539-
540-
/* --- Latin-1 Codecs ----------------------------------------------------- */
541-
542-
PyAPI_FUNC(PyObject*) _PyUnicode_AsLatin1String(
543-
PyObject* unicode,
544-
const char* errors);
545-
546-
/* --- ASCII Codecs ------------------------------------------------------- */
547-
548-
PyAPI_FUNC(PyObject*) _PyUnicode_AsASCIIString(
549-
PyObject* unicode,
550-
const char* errors);
551-
552-
/* --- Character Map Codecs ----------------------------------------------- */
553-
554-
/* Translate an Unicode object by applying a character mapping table to
555-
it and return the resulting Unicode object.
556-
557-
The mapping table must map Unicode ordinal integers to Unicode strings,
558-
Unicode ordinal integers or None (causing deletion of the character).
559-
560-
Mapping tables may be dictionaries or sequences. Unmapped character
561-
ordinals (ones which cause a LookupError) are left untouched and
562-
are copied as-is.
563-
*/
564-
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeCharmap(
565-
PyObject *unicode, /* Unicode object */
566-
PyObject *mapping, /* encoding mapping */
567-
const char *errors /* error handling */
568-
);
569-
570-
/* --- Decimal Encoder ---------------------------------------------------- */
571-
572-
/* Coverts a Unicode object holding a decimal value to an ASCII string
573-
for using in int, float and complex parsers.
574-
Transforms code points that have decimal digit property to the
575-
corresponding ASCII digit code points. Transforms spaces to ASCII.
576-
Transforms code points starting from the first non-ASCII code point that
577-
is neither a decimal digit nor a space to the end into '?'. */
578-
579-
PyAPI_FUNC(PyObject*) _PyUnicode_TransformDecimalAndSpaceToASCII(
580-
PyObject *unicode /* Unicode object */
581-
);
582-
583460
/* === Characters Type APIs =============================================== */
584461

585462
/* These should not be used directly. Use the Py_UNICODE_IS* and
@@ -729,23 +606,3 @@ static inline int Py_UNICODE_ISALNUM(Py_UCS4 ch) {
729606
|| Py_UNICODE_ISDIGIT(ch)
730607
|| Py_UNICODE_ISNUMERIC(ch));
731608
}
732-
733-
734-
/* === Misc functions ===================================================== */
735-
736-
PyAPI_FUNC(PyObject*) _PyUnicode_FormatLong(PyObject *, int, int, int);
737-
738-
/* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/
739-
PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*);
740-
741-
/* Fast equality check when the inputs are known to be exact unicode types
742-
and where the hash values are equal (i.e. a very probable match) */
743-
PyAPI_FUNC(int) _PyUnicode_EQ(PyObject *, PyObject *);
744-
745-
/* Equality check. */
746-
PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *, PyObject *);
747-
748-
PyAPI_FUNC(int) _PyUnicode_WideCharString_Converter(PyObject *, void *);
749-
PyAPI_FUNC(int) _PyUnicode_WideCharString_Opt_Converter(PyObject *, void *);
750-
751-
PyAPI_FUNC(Py_ssize_t) _PyUnicode_ScanIdentifier(PyObject *);

Include/internal/pycore_atexit.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ struct _atexit_runtime_state {
2525
//###################
2626
// interpreter atexit
2727

28-
struct atexit_callback;
28+
typedef void (*atexit_datacallbackfunc)(void *);
29+
2930
typedef struct atexit_callback {
3031
atexit_datacallbackfunc func;
3132
void *data;
@@ -50,6 +51,10 @@ struct atexit_state {
5051
int callback_len;
5152
};
5253

54+
PyAPI_FUNC(int) _Py_AtExit(
55+
PyInterpreterState *interp,
56+
atexit_datacallbackfunc func,
57+
void *data);
5358

5459
#ifdef __cplusplus
5560
}

0 commit comments

Comments
 (0)