Skip to content

Commit 0d72f6b

Browse files
committed
Update Python inlined files: 3.8.5
1 parent c5134ed commit 0d72f6b

File tree

205 files changed

+2990
-1226
lines changed

Some content is hidden

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

205 files changed

+2990
-1226
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ typedef struct {
8888
#define CO_ITERABLE_COROUTINE 0x0100
8989
#define CO_ASYNC_GENERATOR 0x0200
9090

91-
/* These are no longer used. */
92-
#if 0
93-
#define CO_GENERATOR_ALLOWED 0x1000
94-
#endif
95-
#define CO_FUTURE_DIVISION 0x2000
96-
#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */
97-
#define CO_FUTURE_WITH_STATEMENT 0x8000
98-
#define CO_FUTURE_PRINT_FUNCTION 0x10000
99-
#define CO_FUTURE_UNICODE_LITERALS 0x20000
100-
101-
#define CO_FUTURE_BARRY_AS_BDFL 0x40000
102-
#define CO_FUTURE_GENERATOR_STOP 0x80000
103-
#define CO_FUTURE_ANNOTATIONS 0x100000
91+
/* bpo-39562: These constant values are changed in Python 3.9
92+
to prevent collision with compiler flags. CO_FUTURE_ and PyCF_
93+
constants must be kept unique. PyCF_ constants can use bits from
94+
0x0100 to 0x10000. CO_FUTURE_ constants use bits starting at 0x20000. */
95+
#define CO_FUTURE_DIVISION 0x20000
96+
#define CO_FUTURE_ABSOLUTE_IMPORT 0x40000 /* do absolute imports by default */
97+
#define CO_FUTURE_WITH_STATEMENT 0x80000
98+
#define CO_FUTURE_PRINT_FUNCTION 0x100000
99+
#define CO_FUTURE_UNICODE_LITERALS 0x200000
100+
101+
#define CO_FUTURE_BARRY_AS_BDFL 0x400000
102+
#define CO_FUTURE_GENERATOR_STOP 0x800000
103+
#define CO_FUTURE_ANNOTATIONS 0x1000000
104104

105105
/* This value is found in the co_cell2arg array when the associated cell
106106
variable does not correspond to an argument. */

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
1818
CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | \
1919
CO_FUTURE_GENERATOR_STOP | CO_FUTURE_ANNOTATIONS)
2020
#define PyCF_MASK_OBSOLETE (CO_NESTED)
21+
22+
/* bpo-39562: CO_FUTURE_ and PyCF_ constants must be kept unique.
23+
PyCF_ constants can use bits from 0x0100 to 0x10000.
24+
CO_FUTURE_ constants use bits starting at 0x20000. */
2125
#define PyCF_SOURCE_IS_UTF8 0x0100
2226
#define PyCF_DONT_IMPLY_DEDENT 0x0200
2327
#define PyCF_ONLY_AST 0x0400
2428
#define PyCF_IGNORE_COOKIE 0x0800
2529
#define PyCF_TYPE_COMMENTS 0x1000
2630
#define PyCF_ALLOW_TOP_LEVEL_AWAIT 0x2000
31+
#define PyCF_COMPILE_MASK (PyCF_ONLY_AST | PyCF_ALLOW_TOP_LEVEL_AWAIT | \
32+
PyCF_TYPE_COMMENTS | PyCF_DONT_IMPLY_DEDENT)
2733

2834
#ifndef Py_LIMITED_API
2935
typedef struct {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct _ts {
5555
struct _ts *next;
5656
PyInterpreterState *interp;
5757

58+
/* Borrowed reference to the current frame (it can be NULL) */
5859
struct _frame *frame;
5960
int recursion_depth;
6061
char overflowed; /* The stack has overflowed. Allow 50 more calls

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ of data it contains. An object's type is fixed when it is created.
2929
Types themselves are represented as objects; an object contains a
3030
pointer to the corresponding type object. The type itself has a type
3131
pointer pointing to the object representing the type 'type', which
32-
contains a pointer to itself!).
32+
contains a pointer to itself!.
3333
3434
Objects do not float around in memory; once allocated an object keeps
3535
the same size and address. Objects that must hold variable-size data

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
/*--start constants--*/
1919
#define PY_MAJOR_VERSION 3
2020
#define PY_MINOR_VERSION 8
21-
#define PY_MICRO_VERSION 2
21+
#define PY_MICRO_VERSION 5
2222
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL
2323
#define PY_RELEASE_SERIAL 0
2424

2525
/* Version as a string */
26-
#define PY_VERSION "3.8.2"
26+
#define PY_VERSION "3.8.5"
2727
/*--end constants--*/
2828

2929
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.

graalpython/com.oracle.graal.python.cext/modules/_struct.c renamed to graalpython/com.oracle.graal.python.cext/modules/_cpython_struct.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,10 @@ prepare_s(PyStructObject *self)
12851285
size_t ncodes;
12861286

12871287
fmt = PyBytes_AS_STRING(self->s_format);
1288+
if (strlen(fmt) != (size_t)PyBytes_GET_SIZE(self->s_format)) {
1289+
PyErr_SetString(StructError, "embedded null character");
1290+
return -1;
1291+
}
12881292

12891293
f = whichtable(&fmt);
12901294

@@ -2365,6 +2369,9 @@ PyInit__struct(void)
23652369
"unknown" float format */
23662370
if (ptr->format == 'd' || ptr->format == 'f')
23672371
break;
2372+
/* Skip _Bool, semantics are different for standard size */
2373+
if (ptr->format == '?')
2374+
break;
23682375
ptr->pack = native->pack;
23692376
ptr->unpack = native->unpack;
23702377
break;

graalpython/lib-python/3/__future__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@
6868
# this module.
6969
CO_NESTED = 0x0010 # nested_scopes
7070
CO_GENERATOR_ALLOWED = 0 # generators (obsolete, was 0x1000)
71-
CO_FUTURE_DIVISION = 0x2000 # division
72-
CO_FUTURE_ABSOLUTE_IMPORT = 0x4000 # perform absolute imports by default
73-
CO_FUTURE_WITH_STATEMENT = 0x8000 # with statement
74-
CO_FUTURE_PRINT_FUNCTION = 0x10000 # print function
75-
CO_FUTURE_UNICODE_LITERALS = 0x20000 # unicode string literals
76-
CO_FUTURE_BARRY_AS_BDFL = 0x40000
77-
CO_FUTURE_GENERATOR_STOP = 0x80000 # StopIteration becomes RuntimeError in generators
78-
CO_FUTURE_ANNOTATIONS = 0x100000 # annotations become strings at runtime
71+
CO_FUTURE_DIVISION = 0x20000 # division
72+
CO_FUTURE_ABSOLUTE_IMPORT = 0x40000 # perform absolute imports by default
73+
CO_FUTURE_WITH_STATEMENT = 0x80000 # with statement
74+
CO_FUTURE_PRINT_FUNCTION = 0x100000 # print function
75+
CO_FUTURE_UNICODE_LITERALS = 0x200000 # unicode string literals
76+
CO_FUTURE_BARRY_AS_BDFL = 0x400000
77+
CO_FUTURE_GENERATOR_STOP = 0x800000 # StopIteration becomes RuntimeError in generators
78+
CO_FUTURE_ANNOTATIONS = 0x1000000 # annotations become strings at runtime
7979

8080
class _Feature:
8181
def __init__(self, optionalRelease, mandatoryRelease, compiler_flag):

graalpython/lib-python/3/_osx_support.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def _remove_universal_flags(_config_vars):
211211
if cv in _config_vars and cv not in os.environ:
212212
flags = _config_vars[cv]
213213
flags = re.sub(r'-arch\s+\w+\s', ' ', flags, flags=re.ASCII)
214-
flags = re.sub('-isysroot [^ \t]*', ' ', flags)
214+
flags = re.sub(r'-isysroot\s*\S+', ' ', flags)
215215
_save_modified_value(_config_vars, cv, flags)
216216

217217
return _config_vars
@@ -287,15 +287,15 @@ def _check_for_unavailable_sdk(_config_vars):
287287
# to /usr and /System/Library by either a standalone CLT
288288
# package or the CLT component within Xcode.
289289
cflags = _config_vars.get('CFLAGS', '')
290-
m = re.search(r'-isysroot\s+(\S+)', cflags)
290+
m = re.search(r'-isysroot\s*(\S+)', cflags)
291291
if m is not None:
292292
sdk = m.group(1)
293293
if not os.path.exists(sdk):
294294
for cv in _UNIVERSAL_CONFIG_VARS:
295295
# Do not alter a config var explicitly overridden by env var
296296
if cv in _config_vars and cv not in os.environ:
297297
flags = _config_vars[cv]
298-
flags = re.sub(r'-isysroot\s+\S+(?:\s|$)', ' ', flags)
298+
flags = re.sub(r'-isysroot\s*\S+(?:\s|$)', ' ', flags)
299299
_save_modified_value(_config_vars, cv, flags)
300300

301301
return _config_vars
@@ -320,7 +320,7 @@ def compiler_fixup(compiler_so, cc_args):
320320
stripArch = stripSysroot = True
321321
else:
322322
stripArch = '-arch' in cc_args
323-
stripSysroot = '-isysroot' in cc_args
323+
stripSysroot = any(arg for arg in cc_args if arg.startswith('-isysroot'))
324324

325325
if stripArch or 'ARCHFLAGS' in os.environ:
326326
while True:
@@ -338,23 +338,34 @@ def compiler_fixup(compiler_so, cc_args):
338338

339339
if stripSysroot:
340340
while True:
341-
try:
342-
index = compiler_so.index('-isysroot')
341+
indices = [i for i,x in enumerate(compiler_so) if x.startswith('-isysroot')]
342+
if not indices:
343+
break
344+
index = indices[0]
345+
if compiler_so[index] == '-isysroot':
343346
# Strip this argument and the next one:
344347
del compiler_so[index:index+2]
345-
except ValueError:
346-
break
348+
else:
349+
# It's '-isysroot/some/path' in one arg
350+
del compiler_so[index:index+1]
347351

348352
# Check if the SDK that is used during compilation actually exists,
349353
# the universal build requires the usage of a universal SDK and not all
350354
# users have that installed by default.
351355
sysroot = None
352-
if '-isysroot' in cc_args:
353-
idx = cc_args.index('-isysroot')
354-
sysroot = cc_args[idx+1]
355-
elif '-isysroot' in compiler_so:
356-
idx = compiler_so.index('-isysroot')
357-
sysroot = compiler_so[idx+1]
356+
argvar = cc_args
357+
indices = [i for i,x in enumerate(cc_args) if x.startswith('-isysroot')]
358+
if not indices:
359+
argvar = compiler_so
360+
indices = [i for i,x in enumerate(compiler_so) if x.startswith('-isysroot')]
361+
362+
for idx in indices:
363+
if argvar[idx] == '-isysroot':
364+
sysroot = argvar[idx+1]
365+
break
366+
else:
367+
sysroot = argvar[idx][len('-isysroot'):]
368+
break
358369

359370
if sysroot and not os.path.isdir(sysroot):
360371
from distutils import log

graalpython/lib-python/3/_pydecimal.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,11 @@
140140
# Limits for the C version for compatibility
141141
'MAX_PREC', 'MAX_EMAX', 'MIN_EMIN', 'MIN_ETINY',
142142

143-
# C version: compile time choice that enables the thread local context
144-
'HAVE_THREADS'
143+
# C version: compile time choice that enables the thread local context (deprecated, now always true)
144+
'HAVE_THREADS',
145+
146+
# C version: compile time choice that enables the coroutine local context
147+
'HAVE_CONTEXTVAR'
145148
]
146149

147150
__xname__ = __name__ # sys.modules lookup (--without-threads)
@@ -172,6 +175,7 @@
172175

173176
# Compatibility with the C version
174177
HAVE_THREADS = True
178+
HAVE_CONTEXTVAR = True
175179
if sys.maxsize == 2**63-1:
176180
MAX_PREC = 999999999999999999
177181
MAX_EMAX = 999999999999999999

graalpython/lib-python/3/ast.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ def literal_eval(node_or_string):
5959
node_or_string = parse(node_or_string, mode='eval')
6060
if isinstance(node_or_string, Expression):
6161
node_or_string = node_or_string.body
62+
def _raise_malformed_node(node):
63+
raise ValueError(f'malformed node or string: {node!r}')
6264
def _convert_num(node):
63-
if isinstance(node, Constant):
64-
if type(node.value) in (int, float, complex):
65-
return node.value
66-
raise ValueError('malformed node or string: ' + repr(node))
65+
if not isinstance(node, Constant) or type(node.value) not in (int, float, complex):
66+
_raise_malformed_node(node)
67+
return node.value
6768
def _convert_signed_num(node):
6869
if isinstance(node, UnaryOp) and isinstance(node.op, (UAdd, USub)):
6970
operand = _convert_num(node.operand)
@@ -82,6 +83,8 @@ def _convert(node):
8283
elif isinstance(node, Set):
8384
return set(map(_convert, node.elts))
8485
elif isinstance(node, Dict):
86+
if len(node.keys) != len(node.values):
87+
_raise_malformed_node(node)
8588
return dict(zip(map(_convert, node.keys),
8689
map(_convert, node.values)))
8790
elif isinstance(node, BinOp) and isinstance(node.op, (Add, Sub)):
@@ -408,11 +411,11 @@ class NodeTransformer(NodeVisitor):
408411
class RewriteName(NodeTransformer):
409412
410413
def visit_Name(self, node):
411-
return copy_location(Subscript(
414+
return Subscript(
412415
value=Name(id='data', ctx=Load()),
413416
slice=Index(value=Str(s=node.id)),
414417
ctx=node.ctx
415-
), node)
418+
)
416419
417420
Keep in mind that if the node you're operating on has child nodes you must
418421
either transform the child nodes yourself or call the :meth:`generic_visit`
@@ -480,6 +483,13 @@ def __instancecheck__(cls, inst):
480483
return type.__instancecheck__(cls, inst)
481484

482485
def _new(cls, *args, **kwargs):
486+
for key in kwargs:
487+
if key not in cls._fields:
488+
# arbitrary keyword arguments are accepted
489+
continue
490+
pos = cls._fields.index(key)
491+
if pos < len(args):
492+
raise TypeError(f"{cls.__name__} got multiple values for argument {key!r}")
483493
if cls in _const_types:
484494
return Constant(*args, **kwargs)
485495
return Constant.__new__(cls, *args, **kwargs)

0 commit comments

Comments
 (0)