Skip to content

Commit 3e02451

Browse files
committed
update to python 3.8.6
1 parent 5003891 commit 3e02451

Some content is hidden

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

99 files changed

+435
-232
lines changed

PythonLib/full/__future__.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,20 @@
6666
# code.h and used by compile.h, so that an editor search will find them here.
6767
# However, they're not exported in __all__, because they don't really belong to
6868
# this module.
69-
CO_NESTED = 0x0010 # nested_scopes
70-
CO_GENERATOR_ALLOWED = 0 # generators (obsolete, was 0x1000)
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
69+
CO_NESTED = 0x0010 # nested_scopes
70+
CO_GENERATOR_ALLOWED = 0 # generators (obsolete, was 0x1000)
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
7676
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
77+
CO_FUTURE_GENERATOR_STOP = 0x800000 # StopIteration becomes RuntimeError in generators
78+
CO_FUTURE_ANNOTATIONS = 0x1000000 # annotations become strings at runtime
79+
7980

8081
class _Feature:
82+
8183
def __init__(self, optionalRelease, mandatoryRelease, compiler_flag):
8284
self.optional = optionalRelease
8385
self.mandatory = mandatoryRelease
@@ -88,7 +90,6 @@ def getOptionalRelease(self):
8890
8991
This is a 5-tuple, of the same form as sys.version_info.
9092
"""
91-
9293
return self.optional
9394

9495
def getMandatoryRelease(self):
@@ -97,14 +98,14 @@ def getMandatoryRelease(self):
9798
This is a 5-tuple, of the same form as sys.version_info, or, if
9899
the feature was dropped, is None.
99100
"""
100-
101101
return self.mandatory
102102

103103
def __repr__(self):
104104
return "_Feature" + repr((self.optional,
105105
self.mandatory,
106106
self.compiler_flag))
107107

108+
108109
nested_scopes = _Feature((2, 1, 0, "beta", 1),
109110
(2, 2, 0, "alpha", 0),
110111
CO_NESTED)
@@ -142,5 +143,5 @@ def __repr__(self):
142143
CO_FUTURE_GENERATOR_STOP)
143144

144145
annotations = _Feature((3, 7, 0, "beta", 1),
145-
(4, 0, 0, "alpha", 0),
146+
(3, 10, 0, "alpha", 0),
146147
CO_FUTURE_ANNOTATIONS)

PythonLib/full/ast.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,14 @@ def copy_location(new_node, old_node):
144144
attributes) from *old_node* to *new_node* if possible, and return *new_node*.
145145
"""
146146
for attr in 'lineno', 'col_offset', 'end_lineno', 'end_col_offset':
147-
if attr in old_node._attributes and attr in new_node._attributes \
148-
and hasattr(old_node, attr):
149-
setattr(new_node, attr, getattr(old_node, attr))
147+
if attr in old_node._attributes and attr in new_node._attributes:
148+
value = getattr(old_node, attr, None)
149+
# end_lineno and end_col_offset are optional attributes, and they
150+
# should be copied whether the value is None or not.
151+
if value is not None or (
152+
hasattr(old_node, attr) and attr.startswith("end_")
153+
):
154+
setattr(new_node, attr, value)
150155
return new_node
151156

152157

@@ -194,8 +199,11 @@ def increment_lineno(node, n=1):
194199
for child in walk(node):
195200
if 'lineno' in child._attributes:
196201
child.lineno = getattr(child, 'lineno', 0) + n
197-
if 'end_lineno' in child._attributes:
198-
child.end_lineno = getattr(child, 'end_lineno', 0) + n
202+
if (
203+
"end_lineno" in child._attributes
204+
and (end_lineno := getattr(child, "end_lineno", 0)) is not None
205+
):
206+
child.end_lineno = end_lineno + n
199207
return node
200208

201209

PythonLib/full/asyncio/events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def create_task(self, coro, *, name=None):
280280
def call_soon_threadsafe(self, callback, *args):
281281
raise NotImplementedError
282282

283-
async def run_in_executor(self, executor, func, *args):
283+
def run_in_executor(self, executor, func, *args):
284284
raise NotImplementedError
285285

286286
def set_default_executor(self, executor):

PythonLib/full/asyncio/proactor_events.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,14 @@ def _loop_self_reading(self, f=None):
766766
try:
767767
if f is not None:
768768
f.result() # may raise
769+
if self._self_reading_future is not f:
770+
# When we scheduled this Future, we assigned it to
771+
# _self_reading_future. If it's not there now, something has
772+
# tried to cancel the loop while this callback was still in the
773+
# queue (see windows_events.ProactorEventLoop.run_forever). In
774+
# that case stop here instead of continuing to schedule a new
775+
# iteration.
776+
return
769777
f = self._proactor.recv(self._ssock, 4096)
770778
except exceptions.CancelledError:
771779
# _close_self_pipe() has been called, stop waiting for data
@@ -783,8 +791,17 @@ def _loop_self_reading(self, f=None):
783791
f.add_done_callback(self._loop_self_reading)
784792

785793
def _write_to_self(self):
794+
# This may be called from a different thread, possibly after
795+
# _close_self_pipe() has been called or even while it is
796+
# running. Guard for self._csock being None or closed. When
797+
# a socket is closed, send() raises OSError (with errno set to
798+
# EBADF, but let's not rely on the exact error code).
799+
csock = self._csock
800+
if csock is None:
801+
return
802+
786803
try:
787-
self._csock.send(b'\0')
804+
csock.send(b'\0')
788805
except OSError:
789806
if self._debug:
790807
logger.debug("Fail to write a null byte into the "

PythonLib/full/asyncio/runners.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from . import tasks
66

77

8-
def run(main, *, debug=False):
8+
def run(main, *, debug=None):
99
"""Execute the coroutine and return the result.
1010
1111
This function runs the passed coroutine, taking care of
@@ -39,7 +39,8 @@ async def main():
3939
loop = events.new_event_loop()
4040
try:
4141
events.set_event_loop(loop)
42-
loop.set_debug(debug)
42+
if debug is not None:
43+
loop.set_debug(debug)
4344
return loop.run_until_complete(main)
4445
finally:
4546
try:

PythonLib/full/asyncio/selector_events.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,16 @@ def _write_to_self(self):
133133
# a socket is closed, send() raises OSError (with errno set to
134134
# EBADF, but let's not rely on the exact error code).
135135
csock = self._csock
136-
if csock is not None:
137-
try:
138-
csock.send(b'\0')
139-
except OSError:
140-
if self._debug:
141-
logger.debug("Fail to write a null byte into the "
142-
"self-pipe socket",
143-
exc_info=True)
136+
if csock is None:
137+
return
138+
139+
try:
140+
csock.send(b'\0')
141+
except OSError:
142+
if self._debug:
143+
logger.debug("Fail to write a null byte into the "
144+
"self-pipe socket",
145+
exc_info=True)
144146

145147
def _start_serving(self, protocol_factory, sock,
146148
sslcontext=None, server=None, backlog=100,

PythonLib/full/asyncio/tasks.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,13 @@ async def wait_for(fut, timeout, *, loop=None):
460460
if fut.done():
461461
return fut.result()
462462

463-
fut.cancel()
464-
raise exceptions.TimeoutError()
463+
await _cancel_and_wait(fut, loop=loop)
464+
try:
465+
fut.result()
466+
except exceptions.CancelledError as exc:
467+
raise exceptions.TimeoutError() from exc
468+
else:
469+
raise exceptions.TimeoutError()
465470

466471
waiter = loop.create_future()
467472
timeout_handle = loop.call_later(timeout, _release_waiter, waiter)
@@ -475,9 +480,12 @@ async def wait_for(fut, timeout, *, loop=None):
475480
try:
476481
await waiter
477482
except exceptions.CancelledError:
478-
fut.remove_done_callback(cb)
479-
fut.cancel()
480-
raise
483+
if fut.done():
484+
return fut.result()
485+
else:
486+
fut.remove_done_callback(cb)
487+
fut.cancel()
488+
raise
481489

482490
if fut.done():
483491
return fut.result()

PythonLib/full/asyncio/transports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def close(self):
2929
3030
Buffered data will be flushed asynchronously. No more data
3131
will be received. After all buffered data is flushed, the
32-
protocol's connection_lost() method will (eventually) called
33-
with None as its argument.
32+
protocol's connection_lost() method will (eventually) be
33+
called with None as its argument.
3434
"""
3535
raise NotImplementedError
3636

PythonLib/full/asyncio/windows_events.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,12 @@ def run_forever(self):
318318
if self._self_reading_future is not None:
319319
ov = self._self_reading_future._ov
320320
self._self_reading_future.cancel()
321-
# self_reading_future was just cancelled so it will never be signalled
322-
# Unregister it otherwise IocpProactor.close will wait for it forever
321+
# self_reading_future was just cancelled so if it hasn't been
322+
# finished yet, it never will be (it's possible that it has
323+
# already finished and its callback is waiting in the queue,
324+
# where it could still happen if the event loop is restarted).
325+
# Unregister it otherwise IocpProactor.close will wait for it
326+
# forever
323327
if ov is not None:
324328
self._proactor._unregister(ov)
325329
self._self_reading_future = None
@@ -469,7 +473,7 @@ def recv_into(self, conn, buf, flags=0):
469473
else:
470474
ov.ReadFileInto(conn.fileno(), buf)
471475
except BrokenPipeError:
472-
return self._result(b'')
476+
return self._result(0)
473477

474478
def finish_recv(trans, key, ov):
475479
try:

PythonLib/full/codeop.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ def _maybe_compile(compiler, source, filename, symbol):
8484
except SyntaxError as err:
8585
pass
8686

87-
# Suppress warnings after the first compile to avoid duplication.
87+
# Catch syntax warnings after the first compile
88+
# to emit warnings (SyntaxWarning, DeprecationWarning) at most once.
8889
with warnings.catch_warnings():
89-
warnings.simplefilter("ignore")
90+
warnings.simplefilter("error")
91+
9092
try:
9193
code1 = compiler(source + "\n", filename, symbol)
9294
except SyntaxError as e:

0 commit comments

Comments
 (0)