Skip to content

Commit 1ecd293

Browse files
committed
update to python 3.8.3
1 parent 6ee003e commit 1ecd293

File tree

147 files changed

+1778
-605
lines changed

Some content is hidden

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

147 files changed

+1778
-605
lines changed

PythonLib/full/__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):

PythonLib/full/_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

PythonLib/full/_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

PythonLib/full/ast.py

Lines changed: 9 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`

PythonLib/full/asyncio/base_tasks.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,18 @@ def _task_repr_info(task):
2424

2525
def _task_get_stack(task, limit):
2626
frames = []
27-
try:
28-
# 'async def' coroutines
27+
if hasattr(task._coro, 'cr_frame'):
28+
# case 1: 'async def' coroutines
2929
f = task._coro.cr_frame
30-
except AttributeError:
30+
elif hasattr(task._coro, 'gi_frame'):
31+
# case 2: legacy coroutines
3132
f = task._coro.gi_frame
33+
elif hasattr(task._coro, 'ag_frame'):
34+
# case 3: async generators
35+
f = task._coro.ag_frame
36+
else:
37+
# case 4: unknown objects
38+
f = None
3239
if f is not None:
3340
while f is not None:
3441
if limit is not None:

PythonLib/full/codecs.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -905,11 +905,16 @@ def open(filename, mode='r', encoding=None, errors='strict', buffering=-1):
905905
file = builtins.open(filename, mode, buffering)
906906
if encoding is None:
907907
return file
908-
info = lookup(encoding)
909-
srw = StreamReaderWriter(file, info.streamreader, info.streamwriter, errors)
910-
# Add attributes to simplify introspection
911-
srw.encoding = encoding
912-
return srw
908+
909+
try:
910+
info = lookup(encoding)
911+
srw = StreamReaderWriter(file, info.streamreader, info.streamwriter, errors)
912+
# Add attributes to simplify introspection
913+
srw.encoding = encoding
914+
return srw
915+
except:
916+
file.close()
917+
raise
913918

914919
def EncodedFile(file, data_encoding, file_encoding=None, errors='strict'):
915920

PythonLib/full/collections/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,13 @@ def __repr__(self):
695695
#
696696
# To strip negative and zero counts, add-in an empty counter:
697697
# c += Counter()
698+
#
699+
# Rich comparison operators for multiset subset and superset tests
700+
# are deliberately omitted due to semantic conflicts with the
701+
# existing inherited dict equality method. Subset and superset
702+
# semantics ignore zero counts and require that p≤q ∧ p≥q → p=q;
703+
# however, that would not be the case for p=Counter(a=1, b=0)
704+
# and q=Counter(a=1) where the dictionaries are not equal.
698705

699706
def __add__(self, other):
700707
'''Add counts from two counters.

PythonLib/full/compileall.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _walk_dir(dir, ddir=None, maxlevels=10, quiet=0):
4141
else:
4242
dfile = None
4343
if not os.path.isdir(fullname):
44-
yield fullname
44+
yield fullname, ddir
4545
elif (maxlevels > 0 and name != os.curdir and name != os.pardir and
4646
os.path.isdir(fullname) and not os.path.islink(fullname)):
4747
yield from _walk_dir(fullname, ddir=dfile,
@@ -76,28 +76,33 @@ def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
7676
from concurrent.futures import ProcessPoolExecutor
7777
except ImportError:
7878
workers = 1
79-
files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels,
80-
ddir=ddir)
79+
files_and_ddirs = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels,
80+
ddir=ddir)
8181
success = True
8282
if workers != 1 and ProcessPoolExecutor is not None:
8383
# If workers == 0, let ProcessPoolExecutor choose
8484
workers = workers or None
8585
with ProcessPoolExecutor(max_workers=workers) as executor:
86-
results = executor.map(partial(compile_file,
87-
ddir=ddir, force=force,
88-
rx=rx, quiet=quiet,
89-
legacy=legacy,
90-
optimize=optimize,
91-
invalidation_mode=invalidation_mode),
92-
files)
86+
results = executor.map(
87+
partial(_compile_file_tuple,
88+
force=force, rx=rx, quiet=quiet,
89+
legacy=legacy, optimize=optimize,
90+
invalidation_mode=invalidation_mode,
91+
),
92+
files_and_ddirs)
9393
success = min(results, default=True)
9494
else:
95-
for file in files:
96-
if not compile_file(file, ddir, force, rx, quiet,
95+
for file, dfile in files_and_ddirs:
96+
if not compile_file(file, dfile, force, rx, quiet,
9797
legacy, optimize, invalidation_mode):
9898
success = False
9999
return success
100100

101+
def _compile_file_tuple(file_and_dfile, **kwargs):
102+
"""Needs to be toplevel for ProcessPoolExecutor."""
103+
file, dfile = file_and_dfile
104+
return compile_file(file, dfile, **kwargs)
105+
101106
def compile_file(fullname, ddir=None, force=False, rx=None, quiet=0,
102107
legacy=False, optimize=-1,
103108
invalidation_mode=None):

PythonLib/full/ctypes/test/test_loading.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,11 @@ def should_fail(command):
158158
# Relative path (but not just filename) should succeed
159159
should_pass("WinDLL('./_sqlite3.dll')")
160160

161-
# Insecure load flags should succeed
162-
should_pass("WinDLL('_sqlite3.dll', winmode=0)")
161+
# XXX: This test has started failing on Azure Pipelines CI. See
162+
# bpo-40214 for more information.
163+
if 0:
164+
# Insecure load flags should succeed
165+
should_pass("WinDLL('_sqlite3.dll', winmode=0)")
163166

164167
# Full path load without DLL_LOAD_DIR shouldn't find dependency
165168
should_fail("WinDLL(nt._getfullpathname('_sqlite3.dll'), " +

0 commit comments

Comments
 (0)