Skip to content

Commit 61e635e

Browse files
committed
1 parent 09adfc3 commit 61e635e

Some content is hidden

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

67 files changed

+139
-105
lines changed

PythonLib/full/asynchat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
from warnings import warn
5252
warn(
53-
'The asynchat module is deprecated. '
53+
'The asynchat module is deprecated and will be removed in Python 3.12. '
5454
'The recommended replacement is asyncio',
5555
DeprecationWarning,
5656
stacklevel=2)

PythonLib/full/asyncio/locks.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from . import exceptions
88
from . import mixins
9+
from . import tasks
910

1011

1112
class _ContextManagerMixin:
@@ -350,6 +351,7 @@ def __init__(self, value=1, *, loop=mixins._marker):
350351
raise ValueError("Semaphore initial value must be >= 0")
351352
self._value = value
352353
self._waiters = collections.deque()
354+
self._wakeup_scheduled = False
353355

354356
def __repr__(self):
355357
res = super().__repr__()
@@ -363,6 +365,7 @@ def _wake_up_next(self):
363365
waiter = self._waiters.popleft()
364366
if not waiter.done():
365367
waiter.set_result(None)
368+
self._wakeup_scheduled = True
366369
return
367370

368371
def locked(self):
@@ -378,16 +381,17 @@ async def acquire(self):
378381
called release() to make it larger than 0, and then return
379382
True.
380383
"""
381-
while self._value <= 0:
384+
# _wakeup_scheduled is set if *another* task is scheduled to wakeup
385+
# but its acquire() is not resumed yet
386+
while self._wakeup_scheduled or self._value <= 0:
382387
fut = self._get_loop().create_future()
383388
self._waiters.append(fut)
384389
try:
385390
await fut
386-
except:
387-
# See the similar code in Queue.get.
388-
fut.cancel()
389-
if self._value > 0 and not fut.cancelled():
390-
self._wake_up_next()
391+
# reset _wakeup_scheduled *after* waiting for a future
392+
self._wakeup_scheduled = False
393+
except exceptions.CancelledError:
394+
self._wake_up_next()
391395
raise
392396
self._value -= 1
393397
return True

PythonLib/full/asyncore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
errorcode
5959

6060
warnings.warn(
61-
'The asyncore module is deprecated. '
61+
'The asyncore module is deprecated and will be removed in Python 3.12. '
6262
'The recommended replacement is asyncio',
6363
DeprecationWarning,
6464
stacklevel=2)

PythonLib/full/doctest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,6 +2171,7 @@ def __init__(self, test, optionflags=0, setUp=None, tearDown=None,
21712171
unittest.TestCase.__init__(self)
21722172
self._dt_optionflags = optionflags
21732173
self._dt_checker = checker
2174+
self._dt_globs = test.globs.copy()
21742175
self._dt_test = test
21752176
self._dt_setUp = setUp
21762177
self._dt_tearDown = tearDown
@@ -2187,7 +2188,9 @@ def tearDown(self):
21872188
if self._dt_tearDown is not None:
21882189
self._dt_tearDown(test)
21892190

2191+
# restore the original globs
21902192
test.globs.clear()
2193+
test.globs.update(self._dt_globs)
21912194

21922195
def runTest(self):
21932196
test = self._dt_test

PythonLib/full/pydoc.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class or function within a module or module in a package. If the
6969
import sysconfig
7070
import time
7171
import tokenize
72+
import types
7273
import urllib.parse
7374
import warnings
7475
from collections import deque
@@ -90,21 +91,24 @@ def pathdirs():
9091
normdirs.append(normdir)
9192
return dirs
9293

94+
def _isclass(object):
95+
return inspect.isclass(object) and not isinstance(object, types.GenericAlias)
96+
9397
def _findclass(func):
9498
cls = sys.modules.get(func.__module__)
9599
if cls is None:
96100
return None
97101
for name in func.__qualname__.split('.')[:-1]:
98102
cls = getattr(cls, name)
99-
if not inspect.isclass(cls):
103+
if not _isclass(cls):
100104
return None
101105
return cls
102106

103107
def _finddoc(obj):
104108
if inspect.ismethod(obj):
105109
name = obj.__func__.__name__
106110
self = obj.__self__
107-
if (inspect.isclass(self) and
111+
if (_isclass(self) and
108112
getattr(getattr(self, name, None), '__func__') is obj.__func__):
109113
# classmethod
110114
cls = self
@@ -118,7 +122,7 @@ def _finddoc(obj):
118122
elif inspect.isbuiltin(obj):
119123
name = obj.__name__
120124
self = obj.__self__
121-
if (inspect.isclass(self) and
125+
if (_isclass(self) and
122126
self.__qualname__ + '.' + name == obj.__qualname__):
123127
# classmethod
124128
cls = self
@@ -205,7 +209,7 @@ def classname(object, modname):
205209

206210
def isdata(object):
207211
"""Check if an object is of a type that probably means it's data."""
208-
return not (inspect.ismodule(object) or inspect.isclass(object) or
212+
return not (inspect.ismodule(object) or _isclass(object) or
209213
inspect.isroutine(object) or inspect.isframe(object) or
210214
inspect.istraceback(object) or inspect.iscode(object))
211215

@@ -470,7 +474,7 @@ def document(self, object, name=None, *args):
470474
# by lacking a __name__ attribute) and an instance.
471475
try:
472476
if inspect.ismodule(object): return self.docmodule(*args)
473-
if inspect.isclass(object): return self.docclass(*args)
477+
if _isclass(object): return self.docclass(*args)
474478
if inspect.isroutine(object): return self.docroutine(*args)
475479
except AttributeError:
476480
pass
@@ -775,7 +779,7 @@ def docmodule(self, object, name=None, mod=None, *ignored):
775779
modules = inspect.getmembers(object, inspect.ismodule)
776780

777781
classes, cdict = [], {}
778-
for key, value in inspect.getmembers(object, inspect.isclass):
782+
for key, value in inspect.getmembers(object, _isclass):
779783
# if __all__ exists, believe it. Otherwise use old heuristic.
780784
if (all is not None or
781785
(inspect.getmodule(value) or object) is object):
@@ -1217,7 +1221,7 @@ def docmodule(self, object, name=None, mod=None):
12171221
result = result + self.section('DESCRIPTION', desc)
12181222

12191223
classes = []
1220-
for key, value in inspect.getmembers(object, inspect.isclass):
1224+
for key, value in inspect.getmembers(object, _isclass):
12211225
# if __all__ exists, believe it. Otherwise use old heuristic.
12221226
if (all is not None
12231227
or (inspect.getmodule(value) or object) is object):
@@ -1699,7 +1703,7 @@ def describe(thing):
16991703
return 'member descriptor %s.%s.%s' % (
17001704
thing.__objclass__.__module__, thing.__objclass__.__name__,
17011705
thing.__name__)
1702-
if inspect.isclass(thing):
1706+
if _isclass(thing):
17031707
return 'class ' + thing.__name__
17041708
if inspect.isfunction(thing):
17051709
return 'function ' + thing.__name__
@@ -1760,7 +1764,7 @@ def render_doc(thing, title='Python Library Documentation: %s', forceload=0,
17601764
desc += ' in module ' + module.__name__
17611765

17621766
if not (inspect.ismodule(object) or
1763-
inspect.isclass(object) or
1767+
_isclass(object) or
17641768
inspect.isroutine(object) or
17651769
inspect.isdatadescriptor(object) or
17661770
_getdoc(object)):

PythonLib/full/pydoc_data/topics.py

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Autogenerated by Sphinx on Wed Mar 16 11:26:55 2022
2+
# Autogenerated by Sphinx on Wed Mar 23 20:11:40 2022
33
topics = {'assert': 'The "assert" statement\n'
44
'**********************\n'
55
'\n'
@@ -2418,11 +2418,11 @@
24182418
'resulting\n'
24192419
'object is “compatible” with the exception. An object is '
24202420
'compatible\n'
2421-
'with an exception if it is the class or a base class of the '
2422-
'exception\n'
2423-
'object, or a tuple containing an item that is the class or a '
2421+
'with an exception if the object is the class or a *non-virtual '
24242422
'base\n'
2425-
'class of the exception object.\n'
2423+
'class* of the exception object, or a tuple containing an item '
2424+
'that is\n'
2425+
'the class or a non-virtual base class of the exception object.\n'
24262426
'\n'
24272427
'If no except clause matches the exception, the search for an '
24282428
'exception\n'
@@ -4399,15 +4399,17 @@
43994399
'on members\n'
44004400
' of hashed collections including "set", "frozenset", and '
44014401
'"dict".\n'
4402-
' "__hash__()" should return an integer. The only required '
4403-
'property\n'
4404-
' is that objects which compare equal have the same hash '
4405-
'value; it is\n'
4406-
' advised to mix together the hash values of the '
4407-
'components of the\n'
4408-
' object that also play a part in comparison of objects by '
4409-
'packing\n'
4410-
' them into a tuple and hashing the tuple. Example:\n'
4402+
' The "__hash__()" method should return an integer. The '
4403+
'only required\n'
4404+
' property is that objects which compare equal have the '
4405+
'same hash\n'
4406+
' value; it is advised to mix together the hash values of '
4407+
'the\n'
4408+
' components of the object that also play a part in '
4409+
'comparison of\n'
4410+
' objects by packing them into a tuple and hashing the '
4411+
'tuple.\n'
4412+
' Example:\n'
44114413
'\n'
44124414
' def __hash__(self):\n'
44134415
' return hash((self.name, self.nick, self.color))\n'
@@ -5391,11 +5393,11 @@
53915393
'clause is\n'
53925394
'selected depending on the class of the instance: it must '
53935395
'reference the\n'
5394-
'class of the instance or a base class thereof. The instance '
5395-
'can be\n'
5396-
'received by the handler and can carry additional information '
5397-
'about the\n'
5398-
'exceptional condition.\n'
5396+
'class of the instance or a *non-virtual base class* thereof. '
5397+
'The\n'
5398+
'instance can be received by the handler and can carry '
5399+
'additional\n'
5400+
'information about the exceptional condition.\n'
53995401
'\n'
54005402
'Note:\n'
54015403
'\n'
@@ -5730,11 +5732,11 @@
57305732
'clause is\n'
57315733
'selected depending on the class of the instance: it must '
57325734
'reference the\n'
5733-
'class of the instance or a base class thereof. The instance '
5734-
'can be\n'
5735-
'received by the handler and can carry additional information '
5736-
'about the\n'
5737-
'exceptional condition.\n'
5735+
'class of the instance or a *non-virtual base class* thereof. '
5736+
'The\n'
5737+
'instance can be received by the handler and can carry '
5738+
'additional\n'
5739+
'information about the exceptional condition.\n'
57385740
'\n'
57395741
'Note:\n'
57405742
'\n'
@@ -9303,15 +9305,17 @@
93039305
'on members\n'
93049306
' of hashed collections including "set", "frozenset", and '
93059307
'"dict".\n'
9306-
' "__hash__()" should return an integer. The only required '
9307-
'property\n'
9308-
' is that objects which compare equal have the same hash '
9309-
'value; it is\n'
9310-
' advised to mix together the hash values of the components '
9311-
'of the\n'
9312-
' object that also play a part in comparison of objects by '
9313-
'packing\n'
9314-
' them into a tuple and hashing the tuple. Example:\n'
9308+
' The "__hash__()" method should return an integer. The '
9309+
'only required\n'
9310+
' property is that objects which compare equal have the '
9311+
'same hash\n'
9312+
' value; it is advised to mix together the hash values of '
9313+
'the\n'
9314+
' components of the object that also play a part in '
9315+
'comparison of\n'
9316+
' objects by packing them into a tuple and hashing the '
9317+
'tuple.\n'
9318+
' Example:\n'
93159319
'\n'
93169320
' def __hash__(self):\n'
93179321
' return hash((self.name, self.nick, self.color))\n'
@@ -12428,10 +12432,10 @@
1242812432
'exception. For an except clause with an expression, that expression\n'
1242912433
'is evaluated, and the clause matches the exception if the resulting\n'
1243012434
'object is “compatible” with the exception. An object is compatible\n'
12431-
'with an exception if it is the class or a base class of the '
12432-
'exception\n'
12433-
'object, or a tuple containing an item that is the class or a base\n'
12434-
'class of the exception object.\n'
12435+
'with an exception if the object is the class or a *non-virtual base\n'
12436+
'class* of the exception object, or a tuple containing an item that '
12437+
'is\n'
12438+
'the class or a non-virtual base class of the exception object.\n'
1243512439
'\n'
1243612440
'If no except clause matches the exception, the search for an '
1243712441
'exception\n'

PythonLib/full/smtpd.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@
9393
]
9494

9595
warn(
96-
'The smtpd module is deprecated and unmaintained. Please see aiosmtpd '
96+
'The smtpd module is deprecated and unmaintained and will be removed '
97+
'in Python 3.12. Please see aiosmtpd '
9798
'(https://aiosmtpd.readthedocs.io/) for the recommended replacement.',
9899
DeprecationWarning,
99100
stacklevel=2)

PythonLib/full/sre_parse.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,9 +807,11 @@ def _parse(source, state, verbose, nested, first=False):
807807
if not first or subpattern:
808808
import warnings
809809
warnings.warn(
810-
'Flags not at the start of the expression %r%s' % (
810+
'Flags not at the start of the expression %r%s'
811+
' but at position %d' % (
811812
source.string[:20], # truncate long regexes
812813
' (truncated)' if len(source.string) > 20 else '',
814+
start,
813815
),
814816
DeprecationWarning, stacklevel=nested + 6
815817
)

PythonLib/full/unittest/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _convert_name(name):
3939
name = rel_path
4040
# on Windows both '\' and '/' are used as path
4141
# separators. Better to replace both than rely on os.path.sep
42-
return name[:-3].replace('\\', '.').replace('/', '.')
42+
return os.path.normpath(name)[:-3].replace('\\', '.').replace('/', '.')
4343
return name
4444

4545
def _convert_names(names):

0 commit comments

Comments
 (0)