Skip to content

Commit 47959f2

Browse files
committed
Merge branch 'python-import' into msimacek/GR-25013_python_3.8.5_update
2 parents 657cb1c + 0d72f6b commit 47959f2

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
@@ -94,19 +94,19 @@ typedef struct {
9494
#define CO_ITERABLE_COROUTINE 0x0100
9595
#define CO_ASYNC_GENERATOR 0x0200
9696

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

111111
/* This value is found in the co_cell2arg array when the associated cell
112112
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
@@ -24,12 +24,18 @@ PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
2424
CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | \
2525
CO_FUTURE_GENERATOR_STOP | CO_FUTURE_ANNOTATIONS)
2626
#define PyCF_MASK_OBSOLETE (CO_NESTED)
27+
28+
/* bpo-39562: CO_FUTURE_ and PyCF_ constants must be kept unique.
29+
PyCF_ constants can use bits from 0x0100 to 0x10000.
30+
CO_FUTURE_ constants use bits starting at 0x20000. */
2731
#define PyCF_SOURCE_IS_UTF8 0x0100
2832
#define PyCF_DONT_IMPLY_DEDENT 0x0200
2933
#define PyCF_ONLY_AST 0x0400
3034
#define PyCF_IGNORE_COOKIE 0x0800
3135
#define PyCF_TYPE_COMMENTS 0x1000
3236
#define PyCF_ALLOW_TOP_LEVEL_AWAIT 0x2000
37+
#define PyCF_COMPILE_MASK (PyCF_ONLY_AST | PyCF_ALLOW_TOP_LEVEL_AWAIT | \
38+
PyCF_TYPE_COMMENTS | PyCF_DONT_IMPLY_DEDENT)
3339

3440
#ifndef Py_LIMITED_API
3541
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
@@ -60,6 +60,7 @@ struct _ts {
6060
struct _ts *next;
6161
PyInterpreterState *interp;
6262

63+
/* Borrowed reference to the current frame (it can be NULL) */
6364
struct _frame *frame;
6465
int recursion_depth;
6566
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
@@ -34,7 +34,7 @@ of data it contains. An object's type is fixed when it is created.
3434
Types themselves are represented as objects; an object contains a
3535
pointer to the corresponding type object. The type itself has a type
3636
pointer pointing to the object representing the type 'type', which
37-
contains a pointer to itself!).
37+
contains a pointer to itself!.
3838
3939
Objects do not float around in memory; once allocated an object keeps
4040
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
@@ -23,12 +23,12 @@
2323
/*--start constants--*/
2424
#define PY_MAJOR_VERSION 3
2525
#define PY_MINOR_VERSION 8
26-
#define PY_MICRO_VERSION 2
26+
#define PY_MICRO_VERSION 5
2727
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL
2828
#define PY_RELEASE_SERIAL 0
2929

3030
/* Version as a string */
31-
#define PY_VERSION "3.8.2"
31+
#define PY_VERSION "3.8.5"
3232
/*--end constants--*/
3333

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

graalpython/com.oracle.graal.python.cext/modules/_cpython_struct.c

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

12931293
fmt = PyBytes_AS_STRING(self->s_format);
1294+
if (strlen(fmt) != (size_t)PyBytes_GET_SIZE(self->s_format)) {
1295+
PyErr_SetString(StructError, "embedded null character");
1296+
return -1;
1297+
}
12941298

12951299
f = whichtable(&fmt);
12961300

@@ -2371,6 +2375,9 @@ PyInit__cpython_struct(void)
23712375
"unknown" float format */
23722376
if (ptr->format == 'd' || ptr->format == 'f')
23732377
break;
2378+
/* Skip _Bool, semantics are different for standard size */
2379+
if (ptr->format == '?')
2380+
break;
23742381
ptr->pack = native->pack;
23752382
ptr->unpack = native->unpack;
23762383
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
@@ -212,7 +212,7 @@ def _remove_universal_flags(_config_vars):
212212
if cv in _config_vars and cv not in os.environ:
213213
flags = _config_vars[cv]
214214
flags = re.sub(r'-arch\s+\w+\s', ' ', flags, flags=re.ASCII)
215-
flags = re.sub('-isysroot [^ \t]*', ' ', flags)
215+
flags = re.sub(r'-isysroot\s*\S+', ' ', flags)
216216
_save_modified_value(_config_vars, cv, flags)
217217

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

302302
return _config_vars
@@ -321,7 +321,7 @@ def compiler_fixup(compiler_so, cc_args):
321321
stripArch = stripSysroot = True
322322
else:
323323
stripArch = '-arch' in cc_args
324-
stripSysroot = '-isysroot' in cc_args
324+
stripSysroot = any(arg for arg in cc_args if arg.startswith('-isysroot'))
325325

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

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

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

360371
if sysroot and not os.path.isdir(sysroot):
361372
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)