Skip to content

Commit 7967d55

Browse files
committed
Update Python inlined files: 3.11.7
1 parent 8f1105d commit 7967d55

File tree

509 files changed

+34745
-19996
lines changed

Some content is hidden

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

509 files changed

+34745
-19996
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#ifndef Py_CPYTHON_BYTESOBJECT_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
typedef struct {
6+
PyObject_VAR_HEAD
7+
Py_DEPRECATED(3.11) Py_hash_t ob_shash;
8+
char ob_sval[1];
9+
10+
/* Invariants:
11+
* ob_sval contains space for 'ob_size+1' elements.
12+
* ob_sval[ob_size] == 0.
13+
* ob_shash is the hash of the byte string or -1 if not computed yet.
14+
*/
15+
} PyBytesObject;
16+
17+
PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
18+
PyAPI_FUNC(PyObject*) _PyBytes_FormatEx(
19+
const char *format,
20+
Py_ssize_t format_len,
21+
PyObject *args,
22+
int use_bytearray);
23+
PyAPI_FUNC(PyObject*) _PyBytes_FromHex(
24+
PyObject *string,
25+
int use_bytearray);
26+
27+
/* Helper for PyBytes_DecodeEscape that detects invalid escape chars. */
28+
PyAPI_FUNC(PyObject *) _PyBytes_DecodeEscape(const char *, Py_ssize_t,
29+
const char *, const char **);
30+
31+
/* Macros and static inline functions, trading safety for speed */
32+
#define _PyBytes_CAST(op) \
33+
(assert(PyBytes_Check(op)), _Py_CAST(PyBytesObject*, op))
34+
35+
static inline char* PyBytes_AS_STRING(PyObject *op)
36+
{
37+
return _PyBytes_CAST(op)->ob_sval;
38+
}
39+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
40+
# define PyBytes_AS_STRING(op) PyBytes_AS_STRING(_PyObject_CAST(op))
41+
#endif
42+
43+
static inline Py_ssize_t PyBytes_GET_SIZE(PyObject *op) {
44+
PyBytesObject *self = _PyBytes_CAST(op);
45+
return Py_SIZE(self);
46+
}
47+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
48+
# define PyBytes_GET_SIZE(self) PyBytes_GET_SIZE(_PyObject_CAST(self))
49+
#endif
50+
51+
/* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*,
52+
x must be an iterable object. */
53+
PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
54+
55+
56+
/* The _PyBytesWriter structure is big: it contains an embedded "stack buffer".
57+
A _PyBytesWriter variable must be declared at the end of variables in a
58+
function to optimize the memory allocation on the stack. */
59+
typedef struct {
60+
/* bytes, bytearray or NULL (when the small buffer is used) */
61+
PyObject *buffer;
62+
63+
/* Number of allocated size. */
64+
Py_ssize_t allocated;
65+
66+
/* Minimum number of allocated bytes,
67+
incremented by _PyBytesWriter_Prepare() */
68+
Py_ssize_t min_size;
69+
70+
/* If non-zero, use a bytearray instead of a bytes object for buffer. */
71+
int use_bytearray;
72+
73+
/* If non-zero, overallocate the buffer (default: 0).
74+
This flag must be zero if use_bytearray is non-zero. */
75+
int overallocate;
76+
77+
/* Stack buffer */
78+
int use_small_buffer;
79+
char small_buffer[512];
80+
} _PyBytesWriter;
81+
82+
/* Initialize a bytes writer
83+
84+
By default, the overallocation is disabled. Set the overallocate attribute
85+
to control the allocation of the buffer. */
86+
PyAPI_FUNC(void) _PyBytesWriter_Init(_PyBytesWriter *writer);
87+
88+
/* Get the buffer content and reset the writer.
89+
Return a bytes object, or a bytearray object if use_bytearray is non-zero.
90+
Raise an exception and return NULL on error. */
91+
PyAPI_FUNC(PyObject *) _PyBytesWriter_Finish(_PyBytesWriter *writer,
92+
void *str);
93+
94+
/* Deallocate memory of a writer (clear its internal buffer). */
95+
PyAPI_FUNC(void) _PyBytesWriter_Dealloc(_PyBytesWriter *writer);
96+
97+
/* Allocate the buffer to write size bytes.
98+
Return the pointer to the beginning of buffer data.
99+
Raise an exception and return NULL on error. */
100+
PyAPI_FUNC(void*) _PyBytesWriter_Alloc(_PyBytesWriter *writer,
101+
Py_ssize_t size);
102+
103+
/* Ensure that the buffer is large enough to write *size* bytes.
104+
Add size to the writer minimum size (min_size attribute).
105+
106+
str is the current pointer inside the buffer.
107+
Return the updated current pointer inside the buffer.
108+
Raise an exception and return NULL on error. */
109+
PyAPI_FUNC(void*) _PyBytesWriter_Prepare(_PyBytesWriter *writer,
110+
void *str,
111+
Py_ssize_t size);
112+
113+
/* Resize the buffer to make it larger.
114+
The new buffer may be larger than size bytes because of overallocation.
115+
Return the updated current pointer inside the buffer.
116+
Raise an exception and return NULL on error.
117+
118+
Note: size must be greater than the number of allocated bytes in the writer.
119+
120+
This function doesn't use the writer minimum size (min_size attribute).
121+
122+
See also _PyBytesWriter_Prepare().
123+
*/
124+
PyAPI_FUNC(void*) _PyBytesWriter_Resize(_PyBytesWriter *writer,
125+
void *str,
126+
Py_ssize_t size);
127+
128+
/* Write bytes.
129+
Raise an exception and return NULL on error. */
130+
PyAPI_FUNC(void*) _PyBytesWriter_WriteBytes(_PyBytesWriter *writer,
131+
void *str,
132+
const void *bytes,
133+
Py_ssize_t size);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#ifndef Py_CPYTHON_COMPLEXOBJECT_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
typedef struct {
6+
double real;
7+
double imag;
8+
} Py_complex;
9+
10+
/* Operations on complex numbers from complexmodule.c */
11+
12+
PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
13+
PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
14+
PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
15+
PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
16+
PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
17+
PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
18+
PyAPI_FUNC(double) _Py_c_abs(Py_complex);
19+
20+
/* Complex object interface */
21+
22+
/*
23+
PyComplexObject represents a complex number with double-precision
24+
real and imaginary parts.
25+
*/
26+
typedef struct {
27+
PyObject_HEAD
28+
Py_complex cval;
29+
} PyComplexObject;
30+
31+
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
32+
33+
PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
34+
35+
#ifdef Py_BUILD_CORE
36+
/* Format the object based on the format_spec, as defined in PEP 3101
37+
(Advanced String Formatting). */
38+
extern int _PyComplex_FormatAdvancedWriter(
39+
_PyUnicodeWriter *writer,
40+
PyObject *obj,
41+
PyObject *format_spec,
42+
Py_ssize_t start,
43+
Py_ssize_t end);
44+
#endif // Py_BUILD_CORE
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#ifndef Py_CPYTHON_DESCROBJECT_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
6+
void *wrapped);
7+
8+
typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
9+
void *wrapped, PyObject *kwds);
10+
11+
struct wrapperbase {
12+
const char *name;
13+
int offset;
14+
void *function;
15+
wrapperfunc wrapper;
16+
const char *doc;
17+
int flags;
18+
PyObject *name_strobj;
19+
};
20+
21+
/* Flags for above struct */
22+
#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */
23+
24+
/* Various kinds of descriptor objects */
25+
26+
typedef struct {
27+
PyObject_HEAD
28+
PyTypeObject *d_type;
29+
PyObject *d_name;
30+
PyObject *d_qualname;
31+
} PyDescrObject;
32+
33+
#define PyDescr_COMMON PyDescrObject d_common
34+
35+
#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
36+
#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
37+
38+
typedef struct {
39+
PyDescr_COMMON;
40+
PyMethodDef *d_method;
41+
vectorcallfunc vectorcall;
42+
} PyMethodDescrObject;
43+
44+
typedef struct {
45+
PyDescr_COMMON;
46+
PyMemberDef *d_member;
47+
} PyMemberDescrObject;
48+
49+
typedef struct {
50+
PyDescr_COMMON;
51+
PyGetSetDef *d_getset;
52+
} PyGetSetDescrObject;
53+
54+
typedef struct {
55+
PyDescr_COMMON;
56+
struct wrapperbase *d_base;
57+
void *d_wrapped; /* This can be any function pointer */
58+
} PyWrapperDescrObject;
59+
60+
PyAPI_DATA(PyTypeObject) _PyMethodWrapper_Type;
61+
62+
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
63+
struct wrapperbase *, void *);
64+
PyAPI_FUNC(int) PyDescr_IsData(PyObject *);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef Py_CPYTHON_FLOATOBJECT_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
typedef struct {
6+
PyObject_HEAD
7+
double ob_fval;
8+
} PyFloatObject;
9+
10+
// Macro version of PyFloat_AsDouble() trading safety for speed.
11+
// It doesn't check if op is a double object.
12+
#define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval)
13+
14+
15+
PyAPI_FUNC(int) PyFloat_Pack2(double x, char *p, int le);
16+
PyAPI_FUNC(int) PyFloat_Pack4(double x, char *p, int le);
17+
PyAPI_FUNC(int) PyFloat_Pack8(double x, char *p, int le);
18+
19+
PyAPI_FUNC(double) PyFloat_Unpack2(const char *p, int le);
20+
PyAPI_FUNC(double) PyFloat_Unpack4(const char *p, int le);
21+
PyAPI_FUNC(double) PyFloat_Unpack8(const char *p, int le);
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#ifndef Py_CPYTHON_LONGOBJECT_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
PyAPI_FUNC(int) _PyLong_AsInt(PyObject *);
6+
7+
PyAPI_FUNC(int) _PyLong_UnsignedShort_Converter(PyObject *, void *);
8+
PyAPI_FUNC(int) _PyLong_UnsignedInt_Converter(PyObject *, void *);
9+
PyAPI_FUNC(int) _PyLong_UnsignedLong_Converter(PyObject *, void *);
10+
PyAPI_FUNC(int) _PyLong_UnsignedLongLong_Converter(PyObject *, void *);
11+
PyAPI_FUNC(int) _PyLong_Size_t_Converter(PyObject *, void *);
12+
13+
/* _PyLong_Frexp returns a double x and an exponent e such that the
14+
true value is approximately equal to x * 2**e. e is >= 0. x is
15+
0.0 if and only if the input is 0 (in which case, e and x are both
16+
zeroes); otherwise, 0.5 <= abs(x) < 1.0. On overflow, which is
17+
possible if the number of bits doesn't fit into a Py_ssize_t, sets
18+
OverflowError and returns -1.0 for x, 0 for e. */
19+
PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e);
20+
21+
PyAPI_FUNC(PyObject *) PyLong_FromUnicodeObject(PyObject *u, int base);
22+
PyAPI_FUNC(PyObject *) _PyLong_FromBytes(const char *, Py_ssize_t, int);
23+
24+
/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
25+
v must not be NULL, and must be a normalized long.
26+
There are no error cases.
27+
*/
28+
PyAPI_FUNC(int) _PyLong_Sign(PyObject *v);
29+
30+
/* _PyLong_NumBits. Return the number of bits needed to represent the
31+
absolute value of a long. For example, this returns 1 for 1 and -1, 2
32+
for 2 and -2, and 2 for 3 and -3. It returns 0 for 0.
33+
v must not be NULL, and must be a normalized long.
34+
(size_t)-1 is returned and OverflowError set if the true result doesn't
35+
fit in a size_t.
36+
*/
37+
PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v);
38+
39+
/* _PyLong_DivmodNear. Given integers a and b, compute the nearest
40+
integer q to the exact quotient a / b, rounding to the nearest even integer
41+
in the case of a tie. Return (q, r), where r = a - q*b. The remainder r
42+
will satisfy abs(r) <= abs(b)/2, with equality possible only if q is
43+
even.
44+
*/
45+
PyAPI_FUNC(PyObject *) _PyLong_DivmodNear(PyObject *, PyObject *);
46+
47+
/* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in
48+
base 256, and return a Python int with the same numeric value.
49+
If n is 0, the integer is 0. Else:
50+
If little_endian is 1/true, bytes[n-1] is the MSB and bytes[0] the LSB;
51+
else (little_endian is 0/false) bytes[0] is the MSB and bytes[n-1] the
52+
LSB.
53+
If is_signed is 0/false, view the bytes as a non-negative integer.
54+
If is_signed is 1/true, view the bytes as a 2's-complement integer,
55+
non-negative if bit 0x80 of the MSB is clear, negative if set.
56+
Error returns:
57+
+ Return NULL with the appropriate exception set if there's not
58+
enough memory to create the Python int.
59+
*/
60+
PyAPI_FUNC(PyObject *) _PyLong_FromByteArray(
61+
const unsigned char* bytes, size_t n,
62+
int little_endian, int is_signed);
63+
64+
/* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long
65+
v to a base-256 integer, stored in array bytes. Normally return 0,
66+
return -1 on error.
67+
If little_endian is 1/true, store the MSB at bytes[n-1] and the LSB at
68+
bytes[0]; else (little_endian is 0/false) store the MSB at bytes[0] and
69+
the LSB at bytes[n-1].
70+
If is_signed is 0/false, it's an error if v < 0; else (v >= 0) n bytes
71+
are filled and there's nothing special about bit 0x80 of the MSB.
72+
If is_signed is 1/true, bytes is filled with the 2's-complement
73+
representation of v's value. Bit 0x80 of the MSB is the sign bit.
74+
Error returns (-1):
75+
+ is_signed is 0 and v < 0. TypeError is set in this case, and bytes
76+
isn't altered.
77+
+ n isn't big enough to hold the full mathematical value of v. For
78+
example, if is_signed is 0 and there are more digits in the v than
79+
fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of
80+
being large enough to hold a sign bit. OverflowError is set in this
81+
case, but bytes holds the least-significant n bytes of the true value.
82+
*/
83+
PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
84+
unsigned char* bytes, size_t n,
85+
int little_endian, int is_signed);
86+
87+
/* _PyLong_Format: Convert the long to a string object with given base,
88+
appending a base prefix of 0[box] if base is 2, 8 or 16. */
89+
PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *obj, int base);
90+
91+
/* For use by the gcd function in mathmodule.c */
92+
PyAPI_FUNC(PyObject *) _PyLong_GCD(PyObject *, PyObject *);
93+
94+
PyAPI_FUNC(PyObject *) _PyLong_Rshift(PyObject *, size_t);
95+
PyAPI_FUNC(PyObject *) _PyLong_Lshift(PyObject *, size_t);

0 commit comments

Comments
 (0)