Skip to content

Commit 0285692

Browse files
committed
Update Python inlined files: 3.12.7 (3.0)
1 parent 5c3402d commit 0285692

Some content is hidden

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

69 files changed

+30184
-29243
lines changed

graalpython/com.oracle.graal.python.cext/include/cpython/classobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ typedef struct {
4040

4141
PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;
4242

43-
#define PyInstanceMethod_Check(op) Py_IS_TYPE(op, &PyInstanceMethod_Type)
43+
#define PyInstanceMethod_Check(op) Py_IS_TYPE((op), &PyInstanceMethod_Type)
4444

4545
PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *);
4646
PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);

graalpython/com.oracle.graal.python.cext/include/cpython/code.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,16 @@ PyAPI_FUNC(int) PyUnstable_Code_GetExtra(
340340
PyAPI_FUNC(int) PyUnstable_Code_SetExtra(
341341
PyObject *code, Py_ssize_t index, void *extra);
342342
// Old names -- remove when this API changes:
343+
_Py_DEPRECATED_EXTERNALLY(3.12) static inline int
344+
_PyCode_GetExtra(PyObject *code, Py_ssize_t index, void **extra)
345+
{
346+
return PyUnstable_Code_GetExtra(code, index, extra);
347+
}
348+
_Py_DEPRECATED_EXTERNALLY(3.12) static inline int
349+
_PyCode_SetExtra(PyObject *code, Py_ssize_t index, void *extra)
350+
{
351+
return PyUnstable_Code_SetExtra(code, index, extra);
352+
}
343353

344354
/* Equivalent to getattr(code, 'co_code') in Python.
345355
Returns a strong reference to a bytes object. */

graalpython/com.oracle.graal.python.cext/include/cpython/compile.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,26 @@ typedef struct {
3131
#define _PyCompilerFlags_INIT \
3232
(PyCompilerFlags){.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION}
3333

34+
/* source location information */
35+
typedef struct {
36+
int lineno;
37+
int end_lineno;
38+
int col_offset;
39+
int end_col_offset;
40+
} _PyCompilerSrcLocation;
41+
42+
#define SRC_LOCATION_FROM_AST(n) \
43+
(_PyCompilerSrcLocation){ \
44+
.lineno = (n)->lineno, \
45+
.end_lineno = (n)->end_lineno, \
46+
.col_offset = (n)->col_offset, \
47+
.end_col_offset = (n)->end_col_offset }
48+
3449
/* Future feature support */
3550

3651
typedef struct {
37-
int ff_features; /* flags set by future statements */
38-
int ff_lineno; /* line number of last future statement */
52+
int ff_features; /* flags set by future statements */
53+
_PyCompilerSrcLocation ff_location; /* location of last future statement */
3954
} PyFutureFeatures;
4055

4156
#define FUTURE_NESTED_SCOPES "nested_scopes"

graalpython/com.oracle.graal.python.cext/include/cpython/dictobject.h

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ PyAPI_FUNC(int) _PyDict_Next(
5050
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash);
5151

5252
/* Get the number of items of a dictionary. */
53-
#define PyDict_GET_SIZE(mp) (assert(PyDict_Check(mp)),((PyDictObject *)mp)->ma_used)
53+
static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) {
54+
PyDictObject *mp;
55+
assert(PyDict_Check(op));
56+
mp = _Py_CAST(PyDictObject*, op);
57+
return mp->ma_used;
58+
}
59+
#define PyDict_GET_SIZE(op) PyDict_GET_SIZE(_PyObject_CAST(op))
60+
5461
PyAPI_FUNC(int) _PyDict_Contains_KnownHash(PyObject *, PyObject *, Py_hash_t);
5562
PyAPI_FUNC(int) _PyDict_ContainsId(PyObject *, _Py_Identifier *);
5663
PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
@@ -80,3 +87,32 @@ typedef struct {
8087

8188
PyAPI_FUNC(PyObject *) _PyDictView_New(PyObject *, PyTypeObject *);
8289
PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
90+
91+
/* Dictionary watchers */
92+
93+
#define PY_FOREACH_DICT_EVENT(V) \
94+
V(ADDED) \
95+
V(MODIFIED) \
96+
V(DELETED) \
97+
V(CLONED) \
98+
V(CLEARED) \
99+
V(DEALLOCATED)
100+
101+
typedef enum {
102+
#define PY_DEF_EVENT(EVENT) PyDict_EVENT_##EVENT,
103+
PY_FOREACH_DICT_EVENT(PY_DEF_EVENT)
104+
#undef PY_DEF_EVENT
105+
} PyDict_WatchEvent;
106+
107+
// Callback to be invoked when a watched dict is cleared, dealloced, or modified.
108+
// In clear/dealloc case, key and new_value will be NULL. Otherwise, new_value will be the
109+
// new value for key, NULL if key is being deleted.
110+
typedef int(*PyDict_WatchCallback)(PyDict_WatchEvent event, PyObject* dict, PyObject* key, PyObject* new_value);
111+
112+
// Register/unregister a dict-watcher callback
113+
PyAPI_FUNC(int) PyDict_AddWatcher(PyDict_WatchCallback callback);
114+
PyAPI_FUNC(int) PyDict_ClearWatcher(int watcher_id);
115+
116+
// Mark given dictionary as "watched" (callback will be called if it is modified)
117+
PyAPI_FUNC(int) PyDict_Watch(int watcher_id, PyObject* dict);
118+
PyAPI_FUNC(int) PyDict_Unwatch(int watcher_id, PyObject* dict);

graalpython/com.oracle.graal.python.cext/include/cpython/funcobject.h

Lines changed: 94 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern "C" {
88
#endif
99

1010

11-
#define COMMON_FIELDS(PREFIX) \
11+
#define _Py_COMMON_FIELDS(PREFIX) \
1212
PyObject *PREFIX ## globals; \
1313
PyObject *PREFIX ## builtins; \
1414
PyObject *PREFIX ## name; \
@@ -19,7 +19,7 @@ extern "C" {
1919
PyObject *PREFIX ## closure; /* NULL or a tuple of cell objects */
2020

2121
typedef struct {
22-
COMMON_FIELDS(fc_)
22+
_Py_COMMON_FIELDS(fc_)
2323
} PyFrameConstructor;
2424

2525
/* Function objects and code objects should not be confused with each other:
@@ -35,12 +35,13 @@ typedef struct {
3535

3636
typedef struct {
3737
PyObject_HEAD
38-
COMMON_FIELDS(func_)
38+
_Py_COMMON_FIELDS(func_)
3939
PyObject *func_doc; /* The __doc__ attribute, can be anything */
4040
PyObject *func_dict; /* The __dict__ attribute, a dict or NULL */
4141
PyObject *func_weakreflist; /* List of weak references */
4242
PyObject *func_module; /* The __module__ attribute, can be anything */
4343
PyObject *func_annotations; /* Annotations, a dict or NULL */
44+
PyObject *func_typeparams; /* Tuple of active type variables or NULL */
4445
vectorcallfunc vectorcall;
4546
/* Version number for use by specializer.
4647
* Can set to non-zero when we want to specialize.
@@ -59,6 +60,8 @@ typedef struct {
5960
*/
6061
} PyFunctionObject;
6162

63+
#undef _Py_COMMON_FIELDS
64+
6265
PyAPI_DATA(PyTypeObject) PyFunction_Type;
6366

6467
#define PyFunction_Check(op) Py_IS_TYPE((op), &PyFunction_Type)
@@ -84,22 +87,45 @@ PyAPI_FUNC(PyObject *) _PyFunction_Vectorcall(
8487
size_t nargsf,
8588
PyObject *kwnames);
8689

87-
/* Macros for direct access to these values. Type checks are *not*
88-
done, so use with care. */
89-
#define PyFunction_GET_CODE(func) \
90-
(((PyFunctionObject *)func) -> func_code)
91-
#define PyFunction_GET_GLOBALS(func) \
92-
(((PyFunctionObject *)func) -> func_globals)
93-
#define PyFunction_GET_MODULE(func) \
94-
(((PyFunctionObject *)func) -> func_module)
95-
#define PyFunction_GET_DEFAULTS(func) \
96-
(((PyFunctionObject *)func) -> func_defaults)
97-
#define PyFunction_GET_KW_DEFAULTS(func) \
98-
(((PyFunctionObject *)func) -> func_kwdefaults)
99-
#define PyFunction_GET_CLOSURE(func) \
100-
(((PyFunctionObject *)func) -> func_closure)
101-
#define PyFunction_GET_ANNOTATIONS(func) \
102-
(((PyFunctionObject *)func) -> func_annotations)
90+
#define _PyFunction_CAST(func) \
91+
(assert(PyFunction_Check(func)), _Py_CAST(PyFunctionObject*, func))
92+
93+
/* Static inline functions for direct access to these values.
94+
Type checks are *not* done, so use with care. */
95+
static inline PyObject* PyFunction_GET_CODE(PyObject *func) {
96+
return _PyFunction_CAST(func)->func_code;
97+
}
98+
#define PyFunction_GET_CODE(func) PyFunction_GET_CODE(_PyObject_CAST(func))
99+
100+
static inline PyObject* PyFunction_GET_GLOBALS(PyObject *func) {
101+
return _PyFunction_CAST(func)->func_globals;
102+
}
103+
#define PyFunction_GET_GLOBALS(func) PyFunction_GET_GLOBALS(_PyObject_CAST(func))
104+
105+
static inline PyObject* PyFunction_GET_MODULE(PyObject *func) {
106+
return _PyFunction_CAST(func)->func_module;
107+
}
108+
#define PyFunction_GET_MODULE(func) PyFunction_GET_MODULE(_PyObject_CAST(func))
109+
110+
static inline PyObject* PyFunction_GET_DEFAULTS(PyObject *func) {
111+
return _PyFunction_CAST(func)->func_defaults;
112+
}
113+
#define PyFunction_GET_DEFAULTS(func) PyFunction_GET_DEFAULTS(_PyObject_CAST(func))
114+
115+
static inline PyObject* PyFunction_GET_KW_DEFAULTS(PyObject *func) {
116+
return _PyFunction_CAST(func)->func_kwdefaults;
117+
}
118+
#define PyFunction_GET_KW_DEFAULTS(func) PyFunction_GET_KW_DEFAULTS(_PyObject_CAST(func))
119+
120+
static inline PyObject* PyFunction_GET_CLOSURE(PyObject *func) {
121+
return _PyFunction_CAST(func)->func_closure;
122+
}
123+
#define PyFunction_GET_CLOSURE(func) PyFunction_GET_CLOSURE(_PyObject_CAST(func))
124+
125+
static inline PyObject* PyFunction_GET_ANNOTATIONS(PyObject *func) {
126+
return _PyFunction_CAST(func)->func_annotations;
127+
}
128+
#define PyFunction_GET_ANNOTATIONS(func) PyFunction_GET_ANNOTATIONS(_PyObject_CAST(func))
103129

104130
/* The classmethod and staticmethod types lives here, too */
105131
PyAPI_DATA(PyTypeObject) PyClassMethod_Type;
@@ -108,6 +134,55 @@ PyAPI_DATA(PyTypeObject) PyStaticMethod_Type;
108134
PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *);
109135
PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *);
110136

137+
#define PY_FOREACH_FUNC_EVENT(V) \
138+
V(CREATE) \
139+
V(DESTROY) \
140+
V(MODIFY_CODE) \
141+
V(MODIFY_DEFAULTS) \
142+
V(MODIFY_KWDEFAULTS)
143+
144+
typedef enum {
145+
#define PY_DEF_EVENT(EVENT) PyFunction_EVENT_##EVENT,
146+
PY_FOREACH_FUNC_EVENT(PY_DEF_EVENT)
147+
#undef PY_DEF_EVENT
148+
} PyFunction_WatchEvent;
149+
150+
/*
151+
* A callback that is invoked for different events in a function's lifecycle.
152+
*
153+
* The callback is invoked with a borrowed reference to func, after it is
154+
* created and before it is modified or destroyed. The callback should not
155+
* modify func.
156+
*
157+
* When a function's code object, defaults, or kwdefaults are modified the
158+
* callback will be invoked with the respective event and new_value will
159+
* contain a borrowed reference to the new value that is about to be stored in
160+
* the function. Otherwise the third argument is NULL.
161+
*
162+
* If the callback returns with an exception set, it must return -1. Otherwise
163+
* it should return 0.
164+
*/
165+
typedef int (*PyFunction_WatchCallback)(
166+
PyFunction_WatchEvent event,
167+
PyFunctionObject *func,
168+
PyObject *new_value);
169+
170+
/*
171+
* Register a per-interpreter callback that will be invoked for function lifecycle
172+
* events.
173+
*
174+
* Returns a handle that may be passed to PyFunction_ClearWatcher on success,
175+
* or -1 and sets an error if no more handles are available.
176+
*/
177+
PyAPI_FUNC(int) PyFunction_AddWatcher(PyFunction_WatchCallback callback);
178+
179+
/*
180+
* Clear the watcher associated with the watcher_id handle.
181+
*
182+
* Returns 0 on success or -1 if no watcher exists for the supplied id.
183+
*/
184+
PyAPI_FUNC(int) PyFunction_ClearWatcher(int watcher_id);
185+
111186
#ifdef __cplusplus
112187
}
113188
#endif

graalpython/com.oracle.graal.python.cext/include/cpython/genobject.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ extern "C" {
1313
and coroutine objects. */
1414
#define _PyGenObject_HEAD(prefix) \
1515
PyObject_HEAD \
16-
/* The code object backing the generator */ \
17-
PyCodeObject *prefix##_code; \
1816
/* List of weak reference. */ \
1917
PyObject *prefix##_weakreflist; \
2018
/* Name of the generator. */ \
@@ -28,7 +26,7 @@ extern "C" {
2826
char prefix##_running_async; \
2927
/* The frame */ \
3028
int8_t prefix##_frame_state; \
31-
PyObject *prefix##_iframe[1];
29+
PyObject *prefix##_iframe[1]; \
3230

3331
typedef struct {
3432
/* The gi_ prefix is intended to remind of generator-iterator. */
@@ -46,6 +44,7 @@ PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(PyFrameObject *,
4644
PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *);
4745
PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
4846
PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);
47+
PyAPI_FUNC(PyCodeObject *) PyGen_GetCode(PyGenObject *gen);
4948

5049

5150
/* --- PyCoroObject ------------------------------------------------------- */
@@ -78,6 +77,7 @@ PyAPI_FUNC(PyObject *) PyAsyncGen_New(PyFrameObject *,
7877

7978
#define PyAsyncGen_CheckExact(op) Py_IS_TYPE((op), &PyAsyncGen_Type)
8079

80+
#define PyAsyncGenASend_CheckExact(op) Py_IS_TYPE((op), &_PyAsyncGenASend_Type)
8181

8282

8383
#undef _PyGenObject_HEAD

graalpython/com.oracle.graal.python.cext/include/cpython/initconfig.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ PyAPI_FUNC(PyStatus) PyStatus_Exit(int exitcode);
2525
PyAPI_FUNC(int) PyStatus_IsError(PyStatus err);
2626
PyAPI_FUNC(int) PyStatus_IsExit(PyStatus err);
2727
PyAPI_FUNC(int) PyStatus_Exception(PyStatus err);
28+
PyAPI_FUNC(PyObject *) _PyErr_SetFromPyStatus(PyStatus status);
2829

2930
/* --- PyWideStringList ------------------------------------------------ */
3031

@@ -142,6 +143,7 @@ typedef struct PyConfig {
142143
unsigned long hash_seed;
143144
int faulthandler;
144145
int tracemalloc;
146+
int perf_profiling;
145147
int import_time;
146148
int code_debug_ranges;
147149
int show_ref_count;
@@ -177,6 +179,7 @@ typedef struct PyConfig {
177179
wchar_t *check_hash_pycs_mode;
178180
int use_frozen_modules;
179181
int safe_path;
182+
int int_max_str_digits;
180183

181184
/* --- Path configuration inputs ------------ */
182185
int pathconfig_warnings;
@@ -211,10 +214,6 @@ typedef struct PyConfig {
211214
// If equal to 0, stop Python initialization before the "main" phase.
212215
int _init_main;
213216

214-
// If non-zero, disallow threads, subprocesses, and fork.
215-
// Default: 0.
216-
int _isolated_interpreter;
217-
218217
// If non-zero, we believe we're running from a source tree.
219218
int _is_python_build;
220219
} PyConfig;

graalpython/com.oracle.graal.python.cext/include/cpython/longobject.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,8 @@ PyAPI_FUNC(PyObject *) _PyLong_GCD(PyObject *, PyObject *);
9393

9494
PyAPI_FUNC(PyObject *) _PyLong_Rshift(PyObject *, size_t);
9595
PyAPI_FUNC(PyObject *) _PyLong_Lshift(PyObject *, size_t);
96+
97+
98+
PyAPI_FUNC(int) PyUnstable_Long_IsCompact(const PyLongObject* op);
99+
PyAPI_FUNC(Py_ssize_t) PyUnstable_Long_CompactValue(const PyLongObject* op);
100+

graalpython/com.oracle.graal.python.cext/include/cpython/modsupport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ PyAPI_FUNC(PyObject **) _Py_VaBuildStack(
5151
Py_ssize_t *p_nargs);
5252

5353
typedef struct _PyArg_Parser {
54+
int initialized;
5455
const char *format;
5556
const char * const *keywords;
5657
const char *fname;

graalpython/com.oracle.graal.python.cext/include/cpython/objimpl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,6 @@ PyAPI_FUNC(int) PyObject_IS_GC(PyObject *obj);
8787
PyAPI_FUNC(int) PyType_SUPPORTS_WEAKREFS(PyTypeObject *type);
8888

8989
PyAPI_FUNC(PyObject **) PyObject_GET_WEAKREFS_LISTPTR(PyObject *op);
90+
91+
PyAPI_FUNC(PyObject *) PyUnstable_Object_GC_NewWithExtraData(PyTypeObject *,
92+
size_t);

0 commit comments

Comments
 (0)