Skip to content

Commit da9a962

Browse files
committed
Update Python inlined files: Update to CPython 3.7
1 parent 5643e40 commit da9a962

File tree

726 files changed

+86669
-54494
lines changed

Some content is hidden

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

726 files changed

+86669
-54494
lines changed

graalpython/com.oracle.graal.python.cext/include/abstract.h

Lines changed: 746 additions & 1014 deletions
Large diffs are not rendered by default.

graalpython/com.oracle.graal.python.cext/include/bytesobject.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
5252
PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);
5353
PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *);
5454
PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list)
55-
Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
55+
Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
5656
PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...)
57-
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
57+
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
5858
PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *);
5959
PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
6060
PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
@@ -72,8 +72,8 @@ PyAPI_FUNC(PyObject*) _PyBytes_FromHex(
7272
int use_bytearray);
7373
#endif
7474
PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
75-
const char *, Py_ssize_t,
76-
const char *);
75+
const char *, Py_ssize_t,
76+
const char *);
7777
#ifndef Py_LIMITED_API
7878
/* Helper for PyBytes_DecodeEscape that detects invalid escape chars. */
7979
PyAPI_FUNC(PyObject *) _PyBytes_DecodeEscape(const char *, Py_ssize_t,
@@ -132,10 +132,10 @@ PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGrouping(char *buffer,
132132

133133
/* Flags used by string formatting */
134134
#define F_LJUST (1<<0)
135-
#define F_SIGN (1<<1)
135+
#define F_SIGN (1<<1)
136136
#define F_BLANK (1<<2)
137-
#define F_ALT (1<<3)
138-
#define F_ZERO (1<<4)
137+
#define F_ALT (1<<3)
138+
#define F_ZERO (1<<4)
139139

140140
#ifndef Py_LIMITED_API
141141
/* The _PyBytesWriter structure is big: it contains an embedded "stack buffer".

graalpython/com.oracle.graal.python.cext/include/ceval.h

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,32 @@ extern "C" {
77

88
/* Interface to random parts in ceval.c */
99

10+
/* PyEval_CallObjectWithKeywords(), PyEval_CallObject(), PyEval_CallFunction
11+
* and PyEval_CallMethod are kept for backward compatibility: PyObject_Call(),
12+
* PyObject_CallFunction() and PyObject_CallMethod() are recommended to call
13+
* a callable object.
14+
*/
15+
1016
PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
11-
PyObject *func, PyObject *args, PyObject *kwargs);
17+
PyObject *callable,
18+
PyObject *args,
19+
PyObject *kwargs);
1220

1321
/* Inline this */
14-
#define PyEval_CallObject(func,arg) \
15-
PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
22+
#define PyEval_CallObject(callable, arg) \
23+
PyEval_CallObjectWithKeywords(callable, arg, (PyObject *)NULL)
1624

17-
PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj,
25+
PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *callable,
1826
const char *format, ...);
1927
PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
20-
const char *methodname,
28+
const char *name,
2129
const char *format, ...);
2230

2331
#ifndef Py_LIMITED_API
2432
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
2533
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
34+
PyAPI_FUNC(void) _PyEval_SetCoroutineOriginTrackingDepth(int new_depth);
35+
PyAPI_FUNC(int) _PyEval_GetCoroutineOriginTrackingDepth(void);
2636
PyAPI_FUNC(void) _PyEval_SetCoroutineWrapper(PyObject *);
2737
PyAPI_FUNC(PyObject *) _PyEval_GetCoroutineWrapper(void);
2838
PyAPI_FUNC(void) _PyEval_SetAsyncGenFirstiter(PyObject *);
@@ -85,16 +95,19 @@ PyAPI_FUNC(int) Py_GetRecursionLimit(void);
8595
PyThreadState_GET()->overflowed = 0; \
8696
} while(0)
8797
PyAPI_FUNC(int) _Py_CheckRecursiveCall(const char *where);
98+
99+
/* Due to the macros in which it's used, _Py_CheckRecursionLimit is in
100+
the stable ABI. It should be removed therefrom when possible.
101+
*/
88102
PyAPI_DATA(int) _Py_CheckRecursionLimit;
89103

90104
#ifdef USE_STACKCHECK
91-
/* With USE_STACKCHECK, we artificially decrement the recursion limit in order
92-
to trigger regular stack checks in _Py_CheckRecursiveCall(), except if
93-
the "overflowed" flag is set, in which case we need the true value
94-
of _Py_CheckRecursionLimit for _Py_MakeEndRecCheck() to function properly.
105+
/* With USE_STACKCHECK, trigger stack checks in _Py_CheckRecursiveCall()
106+
on every 64th call to Py_EnterRecursiveCall.
95107
*/
96108
# define _Py_MakeRecCheck(x) \
97-
(++(x) > (_Py_CheckRecursionLimit += PyThreadState_GET()->overflowed - 1))
109+
(++(x) > _Py_CheckRecursionLimit || \
110+
++(PyThreadState_GET()->stackcheck_counter) > 64)
98111
#else
99112
# define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit)
100113
#endif
@@ -121,7 +134,6 @@ PyAPI_DATA(int) _Py_CheckRecursionLimit;
121134
PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);
122135
PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);
123136

124-
PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *);
125137
PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *);
126138
PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc);
127139
#ifndef Py_LIMITED_API
@@ -147,15 +159,15 @@ PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(struct _frame *f, int exc);
147159
148160
if (...premature_exit...) {
149161
Py_BLOCK_THREADS
150-
PyErr_SetFromErrno(PyExc_IOError);
162+
PyErr_SetFromErrno(PyExc_OSError);
151163
return NULL;
152164
}
153165
154166
An alternative is:
155167
156168
Py_BLOCK_THREADS
157169
if (...premature_exit...) {
158-
PyErr_SetFromErrno(PyExc_IOError);
170+
PyErr_SetFromErrno(PyExc_OSError);
159171
return NULL;
160172
}
161173
Py_UNBLOCK_THREADS
@@ -176,15 +188,13 @@ PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(struct _frame *f, int exc);
176188
PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);
177189
PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
178190

179-
#ifdef WITH_THREAD
180-
181191
PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
182192
PyAPI_FUNC(void) PyEval_InitThreads(void);
183193
#ifndef Py_LIMITED_API
184194
PyAPI_FUNC(void) _PyEval_FiniThreads(void);
185195
#endif /* !Py_LIMITED_API */
186-
PyAPI_FUNC(void) PyEval_AcquireLock(void);
187-
PyAPI_FUNC(void) PyEval_ReleaseLock(void);
196+
PyAPI_FUNC(void) PyEval_AcquireLock(void) Py_DEPRECATED(3.2);
197+
PyAPI_FUNC(void) PyEval_ReleaseLock(void) /* Py_DEPRECATED(3.2) */;
188198
PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
189199
PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
190200
PyAPI_FUNC(void) PyEval_ReInitThreads(void);
@@ -206,15 +216,6 @@ PyAPI_FUNC(Py_ssize_t) _PyEval_RequestCodeExtraIndex(freefunc);
206216
#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
207217
}
208218

209-
#else /* !WITH_THREAD */
210-
211-
#define Py_BEGIN_ALLOW_THREADS {
212-
#define Py_BLOCK_THREADS
213-
#define Py_UNBLOCK_THREADS
214-
#define Py_END_ALLOW_THREADS }
215-
216-
#endif /* !WITH_THREAD */
217-
218219
#ifndef Py_LIMITED_API
219220
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
220221
PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
3030
#define PyMethod_GET_FUNCTION(meth) \
3131
(((PyMethodObject *)meth) -> im_func)
3232
#define PyMethod_GET_SELF(meth) \
33-
(((PyMethodObject *)meth) -> im_self)
33+
(((PyMethodObject *)meth) -> im_self)
3434

3535
PyAPI_FUNC(int) PyMethod_ClearFreeList(void);
3636

3737
typedef struct {
38-
PyObject_HEAD
39-
PyObject *func;
38+
PyObject_HEAD
39+
PyObject *func;
4040
} PyInstanceMethodObject;
4141

4242
PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;

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

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,29 @@ typedef uint16_t _Py_CODEUNIT;
2020
/* Bytecode object */
2121
typedef struct {
2222
PyObject_HEAD
23-
int co_argcount; /* #arguments, except *args */
24-
int co_kwonlyargcount; /* #keyword only arguments */
25-
int co_nlocals; /* #local variables */
26-
int co_stacksize; /* #entries needed for evaluation stack */
27-
int co_flags; /* CO_..., see below */
28-
int co_firstlineno; /* first source line number */
29-
PyObject *co_code; /* instruction opcodes */
30-
PyObject *co_consts; /* list (constants used) */
31-
PyObject *co_names; /* list of strings (names used) */
32-
PyObject *co_varnames; /* tuple of strings (local variable names) */
33-
PyObject *co_freevars; /* tuple of strings (free variable names) */
23+
int co_argcount; /* #arguments, except *args */
24+
int co_kwonlyargcount; /* #keyword only arguments */
25+
int co_nlocals; /* #local variables */
26+
int co_stacksize; /* #entries needed for evaluation stack */
27+
int co_flags; /* CO_..., see below */
28+
int co_firstlineno; /* first source line number */
29+
PyObject *co_code; /* instruction opcodes */
30+
PyObject *co_consts; /* list (constants used) */
31+
PyObject *co_names; /* list of strings (names used) */
32+
PyObject *co_varnames; /* tuple of strings (local variable names) */
33+
PyObject *co_freevars; /* tuple of strings (free variable names) */
3434
PyObject *co_cellvars; /* tuple of strings (cell variable names) */
3535
/* The rest aren't used in either hash or comparisons, except for co_name,
3636
used in both. This is done to preserve the name and line number
3737
for tracebacks and debuggers; otherwise, constant de-duplication
3838
would collapse identical functions/lambdas defined on different lines.
3939
*/
40-
unsigned char *co_cell2arg; /* Maps cell vars which are arguments. */
41-
PyObject *co_filename; /* unicode (where it was loaded from) */
42-
PyObject *co_name; /* unicode (name, for reference) */
43-
PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See
44-
Objects/lnotab_notes.txt for details. */
45-
void *co_zombieframe; /* for optimization only (see frameobject.c) */
40+
Py_ssize_t *co_cell2arg; /* Maps cell vars which are arguments. */
41+
PyObject *co_filename; /* unicode (where it was loaded from) */
42+
PyObject *co_name; /* unicode (name, for reference) */
43+
PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See
44+
Objects/lnotab_notes.txt for details. */
45+
void *co_zombieframe; /* for optimization only (see frameobject.c) */
4646
PyObject *co_weakreflist; /* to support weakrefs to code objects */
4747
/* Scratch space for extra data relating to the code object.
4848
Type is a void* to keep the format private in codeobject.c to force
@@ -51,10 +51,10 @@ typedef struct {
5151
} PyCodeObject;
5252

5353
/* Masks for co_flags above */
54-
#define CO_OPTIMIZED 0x0001
55-
#define CO_NEWLOCALS 0x0002
56-
#define CO_VARARGS 0x0004
57-
#define CO_VARKEYWORDS 0x0008
54+
#define CO_OPTIMIZED 0x0001
55+
#define CO_NEWLOCALS 0x0002
56+
#define CO_VARARGS 0x0004
57+
#define CO_VARKEYWORDS 0x0008
5858
#define CO_NESTED 0x0010
5959
#define CO_GENERATOR 0x0020
6060
/* The CO_NOFREE flag is set if there are no free or cell variables.
@@ -74,19 +74,19 @@ typedef struct {
7474
#if 0
7575
#define CO_GENERATOR_ALLOWED 0x1000
7676
#endif
77-
#define CO_FUTURE_DIVISION 0x2000
77+
#define CO_FUTURE_DIVISION 0x2000
7878
#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */
7979
#define CO_FUTURE_WITH_STATEMENT 0x8000
8080
#define CO_FUTURE_PRINT_FUNCTION 0x10000
8181
#define CO_FUTURE_UNICODE_LITERALS 0x20000
8282

8383
#define CO_FUTURE_BARRY_AS_BDFL 0x40000
8484
#define CO_FUTURE_GENERATOR_STOP 0x80000
85+
#define CO_FUTURE_ANNOTATIONS 0x100000
8586

8687
/* This value is found in the co_cell2arg array when the associated cell
87-
variable does not correspond to an argument. The maximum number of
88-
arguments is 255 (indexed up to 254), so 255 work as a special flag.*/
89-
#define CO_CELL_NOT_AN_ARG 255
88+
variable does not correspond to an argument. */
89+
#define CO_CELL_NOT_AN_ARG (-1)
9090

9191
/* This should be defined if a future statement modifies the syntax.
9292
For example, when a keyword is added.
@@ -102,9 +102,9 @@ PyAPI_DATA(PyTypeObject) PyCode_Type;
102102

103103
/* Public interface */
104104
PyAPI_FUNC(PyCodeObject *) PyCode_New(
105-
int, int, int, int, int, PyObject *, PyObject *,
106-
PyObject *, PyObject *, PyObject *, PyObject *,
107-
PyObject *, PyObject *, int, PyObject *);
105+
int, int, int, int, int, PyObject *, PyObject *,
106+
PyObject *, PyObject *, PyObject *, PyObject *,
107+
PyObject *, PyObject *, int, PyObject *);
108108
/* same as struct above */
109109

110110
/* Creates a new empty code object with the specified source location. */

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ extern "C" {
1111
/* Public interface */
1212
struct _node; /* Declare the existence of this type */
1313
PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
14+
/* XXX (ncoghlan): Unprefixed type name in a public API! */
15+
16+
#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \
17+
CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \
18+
CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | \
19+
CO_FUTURE_GENERATOR_STOP | CO_FUTURE_ANNOTATIONS)
20+
#define PyCF_MASK_OBSOLETE (CO_NESTED)
21+
#define PyCF_SOURCE_IS_UTF8 0x0100
22+
#define PyCF_DONT_IMPLY_DEDENT 0x0200
23+
#define PyCF_ONLY_AST 0x0400
24+
#define PyCF_IGNORE_COOKIE 0x0800
25+
26+
#ifndef Py_LIMITED_API
27+
typedef struct {
28+
int cf_flags; /* bitmask of CO_xxx flags relevant to future */
29+
} PyCompilerFlags;
30+
#endif
1431

1532
/* Future feature support */
1633

@@ -28,6 +45,7 @@ typedef struct {
2845
#define FUTURE_UNICODE_LITERALS "unicode_literals"
2946
#define FUTURE_BARRY_AS_BDFL "barry_as_FLUFL"
3047
#define FUTURE_GENERATOR_STOP "generator_stop"
48+
#define FUTURE_ANNOTATIONS "annotations"
3149

3250
struct _mod; /* Declare the existence of this type */
3351
#define PyAST_Compile(mod, s, f, ar) PyAST_CompileEx(mod, s, f, -1, ar)
@@ -58,6 +76,8 @@ PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
5876
#define PY_INVALID_STACK_EFFECT INT_MAX
5977
PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg);
6078

79+
PyAPI_FUNC(int) _PyAST_Optimize(struct _mod *, PyArena *arena, int optimize);
80+
6181
#ifdef __cplusplus
6282
}
6383
#endif

graalpython/com.oracle.graal.python.cext/include/datetime.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,16 @@ typedef struct {
155155
PyTypeObject *DeltaType;
156156
PyTypeObject *TZInfoType;
157157

158+
/* singletons */
159+
PyObject *TimeZone_UTC;
160+
158161
/* constructors */
159162
PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*);
160163
PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int,
161164
PyObject*, PyTypeObject*);
162165
PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*);
163166
PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*);
167+
PyObject *(*TimeZone_FromTimeZone)(PyObject *offset, PyObject *name);
164168

165169
/* constructors for the DB API */
166170
PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*);
@@ -202,6 +206,9 @@ static PyDateTime_CAPI *PyDateTimeAPI = NULL;
202206
#define PyDateTime_IMPORT \
203207
PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0)
204208

209+
/* Macro for access to the UTC singleton */
210+
#define PyDateTime_TimeZone_UTC PyDateTimeAPI->TimeZone_UTC
211+
205212
/* Macros for type checking when not building the Python core. */
206213
#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType)
207214
#define PyDate_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateType)
@@ -242,6 +249,12 @@ static PyDateTime_CAPI *PyDateTimeAPI = NULL;
242249
PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \
243250
PyDateTimeAPI->DeltaType)
244251

252+
#define PyTimeZone_FromOffset(offset) \
253+
PyDateTimeAPI->TimeZone_FromTimeZone(offset, NULL)
254+
255+
#define PyTimeZone_FromOffsetAndName(offset, name) \
256+
PyDateTimeAPI->TimeZone_FromTimeZone(offset, name)
257+
245258
/* Macros supporting the DB API. */
246259
#define PyDateTime_FromTimestamp(args) \
247260
PyDateTimeAPI->DateTime_FromTimestamp( \

graalpython/com.oracle.graal.python.cext/include/descrobject.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ typedef PyObject *(*getter)(PyObject *, void *);
99
typedef int (*setter)(PyObject *, PyObject *, void *);
1010

1111
typedef struct PyGetSetDef {
12-
char *name;
12+
const char *name;
1313
getter get;
1414
setter set;
15-
char *doc;
15+
const char *doc;
1616
void *closure;
1717
} PyGetSetDef;
1818

@@ -24,11 +24,11 @@ typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
2424
void *wrapped, PyObject *kwds);
2525

2626
struct wrapperbase {
27-
char *name;
27+
const char *name;
2828
int offset;
2929
void *function;
3030
wrapperfunc wrapper;
31-
char *doc;
31+
const char *doc;
3232
int flags;
3333
PyObject *name_strobj;
3434
};
@@ -90,6 +90,9 @@ PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
9090
PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
9191
struct PyGetSetDef *);
9292
#ifndef Py_LIMITED_API
93+
94+
PyAPI_FUNC(PyObject *) _PyMethodDescr_FastCallKeywords(
95+
PyObject *descrobj, PyObject *const *stack, Py_ssize_t nargs, PyObject *kwnames);
9396
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
9497
struct wrapperbase *, void *);
9598
#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)

0 commit comments

Comments
 (0)