Skip to content

Commit f74f266

Browse files
committed
update python to 3.10.9
1 parent 4bfa817 commit f74f266

File tree

107 files changed

+932
-377
lines changed

Some content is hidden

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

107 files changed

+932
-377
lines changed

PythonLib/full/_collections_abc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ def __new__(cls, origin, args):
441441
def __parameters__(self):
442442
params = []
443443
for arg in self.__args__:
444+
if isinstance(arg, type) and not isinstance(arg, GenericAlias):
445+
continue
444446
# Looks like a genericalias
445447
if hasattr(arg, "__parameters__") and isinstance(arg.__parameters__, tuple):
446448
params.extend(arg.__parameters__)
@@ -486,6 +488,9 @@ def __getitem__(self, item):
486488
subst = dict(zip(self.__parameters__, item))
487489
new_args = []
488490
for arg in self.__args__:
491+
if isinstance(arg, type) and not isinstance(arg, GenericAlias):
492+
new_args.append(arg)
493+
continue
489494
if _is_typevarlike(arg):
490495
if _is_param_expr(arg):
491496
arg = subst[arg]

PythonLib/full/argparse.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,11 @@ def consume_optional(start_index):
19621962
# arguments, try to parse more single-dash options out
19631963
# of the tail of the option string
19641964
chars = self.prefix_chars
1965-
if arg_count == 0 and option_string[1] not in chars:
1965+
if (
1966+
arg_count == 0
1967+
and option_string[1] not in chars
1968+
and explicit_arg != ''
1969+
):
19661970
action_tuples.append((action, [], option_string))
19671971
char = option_string[0]
19681972
option_string = char + explicit_arg[0]

PythonLib/full/ast.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ def increment_lineno(node, n=1):
236236
location in a file.
237237
"""
238238
for child in walk(node):
239+
# TypeIgnore is a special case where lineno is not an attribute
240+
# but rather a field of the node itself.
241+
if isinstance(child, TypeIgnore):
242+
child.lineno = getattr(child, 'lineno', 0) + n
243+
continue
244+
239245
if 'lineno' in child._attributes:
240246
child.lineno = getattr(child, 'lineno', 0) + n
241247
if (

PythonLib/full/asyncio/base_events.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,8 @@ async def _connect_sock(self, exceptions, addr_info, local_addr_infos=None):
971971
if sock is not None:
972972
sock.close()
973973
raise
974+
finally:
975+
exceptions = my_exceptions = None
974976

975977
async def create_connection(
976978
self, protocol_factory, host=None, port=None,
@@ -1063,17 +1065,20 @@ async def create_connection(
10631065

10641066
if sock is None:
10651067
exceptions = [exc for sub in exceptions for exc in sub]
1066-
if len(exceptions) == 1:
1067-
raise exceptions[0]
1068-
else:
1069-
# If they all have the same str(), raise one.
1070-
model = str(exceptions[0])
1071-
if all(str(exc) == model for exc in exceptions):
1068+
try:
1069+
if len(exceptions) == 1:
10721070
raise exceptions[0]
1073-
# Raise a combined exception so the user can see all
1074-
# the various error messages.
1075-
raise OSError('Multiple exceptions: {}'.format(
1076-
', '.join(str(exc) for exc in exceptions)))
1071+
else:
1072+
# If they all have the same str(), raise one.
1073+
model = str(exceptions[0])
1074+
if all(str(exc) == model for exc in exceptions):
1075+
raise exceptions[0]
1076+
# Raise a combined exception so the user can see all
1077+
# the various error messages.
1078+
raise OSError('Multiple exceptions: {}'.format(
1079+
', '.join(str(exc) for exc in exceptions)))
1080+
finally:
1081+
exceptions = None
10771082

10781083
else:
10791084
if sock is None:
@@ -1862,6 +1867,8 @@ def _run_once(self):
18621867

18631868
event_list = self._selector.select(timeout)
18641869
self._process_events(event_list)
1870+
# Needed to break cycles when an exception occurs.
1871+
event_list = None
18651872

18661873
# Handle 'later' callbacks that are ready.
18671874
end_time = self.time() + self._clock_resolution

PythonLib/full/asyncio/events.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,21 @@ def get_event_loop(self):
650650
if (self._local._loop is None and
651651
not self._local._set_called and
652652
threading.current_thread() is threading.main_thread()):
653+
stacklevel = 2
654+
try:
655+
f = sys._getframe(1)
656+
except AttributeError:
657+
pass
658+
else:
659+
while f:
660+
module = f.f_globals.get('__name__')
661+
if not (module == 'asyncio' or module.startswith('asyncio.')):
662+
break
663+
f = f.f_back
664+
stacklevel += 1
665+
import warnings
666+
warnings.warn('There is no current event loop',
667+
DeprecationWarning, stacklevel=stacklevel)
653668
self.set_event_loop(self.new_event_loop())
654669

655670
if self._local._loop is None:
@@ -763,12 +778,13 @@ def get_event_loop():
763778

764779

765780
def _get_event_loop(stacklevel=3):
781+
# This internal method is going away in Python 3.12, left here only for
782+
# backwards compatibility with 3.10.0 - 3.10.8 and 3.11.0.
783+
# Similarly, this method's C equivalent in _asyncio is going away as well.
784+
# See GH-99949 for more details.
766785
current_loop = _get_running_loop()
767786
if current_loop is not None:
768787
return current_loop
769-
import warnings
770-
warnings.warn('There is no current event loop',
771-
DeprecationWarning, stacklevel=stacklevel)
772788
return get_event_loop_policy().get_event_loop()
773789

774790

PythonLib/full/asyncio/proactor_events.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def __init__(self, loop, sock, protocol, waiter=None,
6060
self._pending_write = 0
6161
self._conn_lost = 0
6262
self._closing = False # Set when close() called.
63+
self._called_connection_lost = False
6364
self._eof_written = False
6465
if self._server is not None:
6566
self._server._attach()
@@ -136,7 +137,7 @@ def _force_close(self, exc):
136137
self._empty_waiter.set_result(None)
137138
else:
138139
self._empty_waiter.set_exception(exc)
139-
if self._closing:
140+
if self._closing and self._called_connection_lost:
140141
return
141142
self._closing = True
142143
self._conn_lost += 1
@@ -151,6 +152,8 @@ def _force_close(self, exc):
151152
self._loop.call_soon(self._call_connection_lost, exc)
152153

153154
def _call_connection_lost(self, exc):
155+
if self._called_connection_lost:
156+
return
154157
try:
155158
self._protocol.connection_lost(exc)
156159
finally:
@@ -166,6 +169,7 @@ def _call_connection_lost(self, exc):
166169
if server is not None:
167170
server._detach()
168171
self._server = None
172+
self._called_connection_lost = True
169173

170174
def get_write_buffer_size(self):
171175
size = self._pending_write

PythonLib/full/asyncio/selector_events.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,11 @@ async def sock_connect(self, sock, address):
497497

498498
fut = self.create_future()
499499
self._sock_connect(fut, sock, address)
500-
return await fut
500+
try:
501+
return await fut
502+
finally:
503+
# Needed to break cycles when an exception occurs.
504+
fut = None
501505

502506
def _sock_connect(self, fut, sock, address):
503507
fd = sock.fileno()
@@ -519,6 +523,8 @@ def _sock_connect(self, fut, sock, address):
519523
fut.set_exception(exc)
520524
else:
521525
fut.set_result(None)
526+
finally:
527+
fut = None
522528

523529
def _sock_write_done(self, fd, fut, handle=None):
524530
if handle is None or not handle.cancelled():
@@ -542,6 +548,8 @@ def _sock_connect_cb(self, fut, sock, address):
542548
fut.set_exception(exc)
543549
else:
544550
fut.set_result(None)
551+
finally:
552+
fut = None
545553

546554
async def sock_accept(self, sock):
547555
"""Accept a connection.

PythonLib/full/asyncio/unix_events.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,12 +789,11 @@ class _UnixSubprocessTransport(base_subprocess.BaseSubprocessTransport):
789789

790790
def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs):
791791
stdin_w = None
792-
if stdin == subprocess.PIPE:
793-
# Use a socket pair for stdin, since not all platforms
792+
if stdin == subprocess.PIPE and sys.platform.startswith('aix'):
793+
# Use a socket pair for stdin on AIX, since it does not
794794
# support selecting read events on the write end of a
795795
# socket (which we use in order to detect closing of the
796-
# other end). Notably this is needed on AIX, and works
797-
# just fine on other platforms.
796+
# other end).
798797
stdin, stdin_w = socket.socketpair()
799798
try:
800799
self._proc = subprocess.Popen(

PythonLib/full/asyncio/windows_events.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,11 @@ def select(self, timeout=None):
439439
self._poll(timeout)
440440
tmp = self._results
441441
self._results = []
442-
return tmp
442+
try:
443+
return tmp
444+
finally:
445+
# Needed to break cycles when an exception occurs.
446+
tmp = None
443447

444448
def _result(self, value):
445449
fut = self._loop.create_future()
@@ -821,6 +825,8 @@ def _poll(self, timeout=None):
821825
else:
822826
f.set_result(value)
823827
self._results.append(f)
828+
finally:
829+
f = None
824830

825831
# Remove unregistered futures
826832
for ov in self._unregistered:

PythonLib/full/codecs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,8 @@ def open(filename, mode='r', encoding=None, errors='strict', buffering=-1):
878878
codecs. Output is also codec dependent and will usually be
879879
Unicode as well.
880880
881-
Underlying encoded files are always opened in binary mode.
881+
If encoding is not None, then the
882+
underlying encoded files are always opened in binary mode.
882883
The default file mode is 'r', meaning to open the file in read mode.
883884
884885
encoding specifies the encoding which is to be used for the

0 commit comments

Comments
 (0)