Skip to content

Commit 68d65a7

Browse files
authored
Updated token + weakref libraries + weakref test - v3.13.11 (#6633)
* Updated the token library * Updated the weakref library * Annotated the failing weakref test
1 parent f929a6e commit 68d65a7

File tree

4 files changed

+45
-63
lines changed

4 files changed

+45
-63
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ def _acquire_release(lock, timeout, l=None, n=1):
14591459
for _ in range(n):
14601460
lock.release()
14611461

1462-
@unittest.skip("TODO: RUSTPYTHON; flaky test")
1462+
@unittest.expectedFailureIf(sys.platform == "darwin", "TODO: RUSTPYTHON")
14631463
def test_repr_rlock(self):
14641464
if self.TYPE != 'processes':
14651465
self.skipTest('test not appropriate for {}'.format(self.TYPE))

Lib/test/test_weakref.py

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,7 @@ def test_ref_reuse(self):
289289
self.assertEqual(weakref.getweakrefcount(o), 1,
290290
"wrong weak ref count for object after deleting proxy")
291291

292-
# TODO: RUSTPYTHON
293-
@unittest.expectedFailure
292+
@unittest.expectedFailure # TODO: RUSTPYTHON
294293
def test_proxy_reuse(self):
295294
o = C()
296295
proxy1 = weakref.proxy(o)
@@ -338,8 +337,7 @@ def __bytes__(self):
338337
self.assertIn("__bytes__", dir(weakref.proxy(instance)))
339338
self.assertEqual(bytes(weakref.proxy(instance)), b"bytes")
340339

341-
# TODO: RUSTPYTHON
342-
@unittest.expectedFailure
340+
@unittest.expectedFailure # TODO: RUSTPYTHON
343341
def test_proxy_index(self):
344342
class C:
345343
def __index__(self):
@@ -348,8 +346,7 @@ def __index__(self):
348346
p = weakref.proxy(o)
349347
self.assertEqual(operator.index(p), 10)
350348

351-
# TODO: RUSTPYTHON
352-
@unittest.expectedFailure
349+
@unittest.expectedFailure # TODO: RUSTPYTHON
353350
def test_proxy_div(self):
354351
class C:
355352
def __floordiv__(self, other):
@@ -362,8 +359,7 @@ def __ifloordiv__(self, other):
362359
p //= 5
363360
self.assertEqual(p, 21)
364361

365-
# TODO: RUSTPYTHON
366-
@unittest.expectedFailure
362+
@unittest.expectedFailure # TODO: RUSTPYTHON
367363
def test_proxy_matmul(self):
368364
class C:
369365
def __matmul__(self, other):
@@ -387,13 +383,11 @@ def __imatmul__(self, other):
387383
# was not honored, and was broken in different ways for
388384
# PyWeakref_NewRef() and PyWeakref_NewProxy(). (Two tests.)
389385

390-
# TODO: RUSTPYTHON
391-
@unittest.expectedFailure
386+
@unittest.expectedFailure # TODO: RUSTPYTHON
392387
def test_shared_ref_without_callback(self):
393388
self.check_shared_without_callback(weakref.ref)
394389

395-
# TODO: RUSTPYTHON
396-
@unittest.expectedFailure
390+
@unittest.expectedFailure # TODO: RUSTPYTHON
397391
def test_shared_proxy_without_callback(self):
398392
self.check_shared_without_callback(weakref.proxy)
399393

@@ -415,8 +409,7 @@ def check_shared_without_callback(self, makeref):
415409
p2 = makeref(o)
416410
self.assertIs(p1, p2, "callbacks were None, NULL in the C API")
417411

418-
# TODO: RUSTPYTHON
419-
@unittest.expectedFailure
412+
@unittest.expectedFailure # TODO: RUSTPYTHON
420413
def test_callable_proxy(self):
421414
o = Callable()
422415
ref1 = weakref.proxy(o)
@@ -511,8 +504,7 @@ def __iter__(self):
511504
# Calls proxy.__next__
512505
self.assertEqual(list(weak_it), [4, 5, 6])
513506

514-
# TODO: RUSTPYTHON
515-
@unittest.expectedFailure
507+
@unittest.expectedFailure # TODO: RUSTPYTHON
516508
def test_proxy_bad_next(self):
517509
# bpo-44720: PyIter_Next() shouldn't be called if the reference
518510
# isn't an iterator.
@@ -602,8 +594,7 @@ def test_getweakrefs(self):
602594
self.assertEqual(weakref.getweakrefs(1), [],
603595
"list of refs does not match for int")
604596

605-
# TODO: RUSTPYTHON
606-
@unittest.expectedFailure
597+
@unittest.expectedFailure # TODO: RUSTPYTHON
607598
def test_newstyle_number_ops(self):
608599
class F(float):
609600
pass
@@ -770,8 +761,7 @@ class D:
770761
del c1, c2, C, D
771762
gc.collect()
772763

773-
# TODO: RUSTPYTHON
774-
@unittest.expectedFailure
764+
@unittest.expectedFailure # TODO: RUSTPYTHON
775765
@suppress_immortalization()
776766
def test_callback_in_cycle_resurrection(self):
777767
import gc
@@ -819,8 +809,7 @@ def C_went_away(ignore):
819809
gc.collect()
820810
self.assertEqual(alist, [])
821811

822-
# TODO: RUSTPYTHON
823-
@unittest.expectedFailure
812+
@unittest.expectedFailure # TODO: RUSTPYTHON
824813
def test_callbacks_on_callback(self):
825814
import gc
826815

@@ -859,13 +848,11 @@ def cb(self, ignore):
859848
gc.collect()
860849
self.assertEqual(alist, [])
861850

862-
# TODO: RUSTPYTHON
863-
@unittest.expectedFailure
851+
@unittest.expectedFailure # TODO: RUSTPYTHON
864852
def test_gc_during_ref_creation(self):
865853
self.check_gc_during_creation(weakref.ref)
866854

867-
# TODO: RUSTPYTHON
868-
@unittest.expectedFailure
855+
@unittest.expectedFailure # TODO: RUSTPYTHON
869856
def test_gc_during_proxy_creation(self):
870857
self.check_gc_during_creation(weakref.proxy)
871858

@@ -1016,8 +1003,7 @@ def cb(wparent):
10161003
del root
10171004
gc.collect()
10181005

1019-
# TODO: RUSTPYTHON
1020-
@unittest.expectedFailure
1006+
@unittest.expectedFailure # TODO: RUSTPYTHON
10211007
def test_callback_attribute(self):
10221008
x = Object(1)
10231009
callback = lambda ref: None
@@ -1027,8 +1013,7 @@ def test_callback_attribute(self):
10271013
ref2 = weakref.ref(x)
10281014
self.assertIsNone(ref2.__callback__)
10291015

1030-
# TODO: RUSTPYTHON
1031-
@unittest.expectedFailure
1016+
@unittest.expectedFailure # TODO: RUSTPYTHON
10321017
def test_callback_attribute_after_deletion(self):
10331018
x = Object(1)
10341019
ref = weakref.ref(x, self.callback)
@@ -1080,8 +1065,7 @@ def callback(obj):
10801065

10811066
class SubclassableWeakrefTestCase(TestBase):
10821067

1083-
# TODO: RUSTPYTHON
1084-
@unittest.expectedFailure
1068+
@unittest.expectedFailure # TODO: RUSTPYTHON
10851069
def test_subclass_refs(self):
10861070
class MyRef(weakref.ref):
10871071
def __init__(self, ob, callback=None, value=42):
@@ -1100,8 +1084,7 @@ def __call__(self):
11001084
self.assertIsNone(mr())
11011085
self.assertTrue(mr.called)
11021086

1103-
# TODO: RUSTPYTHON
1104-
@unittest.expectedFailure
1087+
@unittest.expectedFailure # TODO: RUSTPYTHON
11051088
def test_subclass_refs_dont_replace_standard_refs(self):
11061089
class MyRef(weakref.ref):
11071090
pass
@@ -1353,13 +1336,11 @@ def check_len_cycles(self, dict_type, cons):
13531336
self.assertIn(n1, (0, 1))
13541337
self.assertEqual(n2, 0)
13551338

1356-
# TODO: RUSTPYTHON
1357-
@unittest.expectedFailure
1339+
@unittest.expectedFailure # TODO: RUSTPYTHON
13581340
def test_weak_keyed_len_cycles(self):
13591341
self.check_len_cycles(weakref.WeakKeyDictionary, lambda k: (k, 1))
13601342

1361-
# TODO: RUSTPYTHON
1362-
@unittest.expectedFailure
1343+
@unittest.expectedFailure # TODO: RUSTPYTHON
13631344
def test_weak_valued_len_cycles(self):
13641345
self.check_len_cycles(weakref.WeakValueDictionary, lambda k: (1, k))
13651346

@@ -1387,13 +1368,11 @@ def check_len_race(self, dict_type, cons):
13871368
self.assertGreaterEqual(n2, 0)
13881369
self.assertLessEqual(n2, n1)
13891370

1390-
# TODO: RUSTPYTHON
1391-
@unittest.expectedFailure
1371+
@unittest.expectedFailure # TODO: RUSTPYTHON
13921372
def test_weak_keyed_len_race(self):
13931373
self.check_len_race(weakref.WeakKeyDictionary, lambda k: (k, 1))
13941374

1395-
# TODO: RUSTPYTHON
1396-
@unittest.expectedFailure
1375+
@unittest.expectedFailure # TODO: RUSTPYTHON
13971376
def test_weak_valued_len_race(self):
13981377
self.check_len_race(weakref.WeakValueDictionary, lambda k: (1, k))
13991378

@@ -1894,8 +1873,7 @@ def test_weak_valued_delitem(self):
18941873
self.assertEqual(len(d), 1)
18951874
self.assertEqual(list(d.items()), [('something else', o2)])
18961875

1897-
# TODO: RUSTPYTHON
1898-
@unittest.expectedFailure
1876+
@unittest.expectedFailure # TODO: RUSTPYTHON
18991877
def test_weak_keyed_bad_delitem(self):
19001878
d = weakref.WeakKeyDictionary()
19011879
o = Object('1')
@@ -2088,7 +2066,7 @@ def test_threaded_weak_key_dict_deepcopy(self):
20882066
# copying should not result in a crash.
20892067
self.check_threaded_weak_dict_copy(weakref.WeakKeyDictionary, True)
20902068

2091-
@unittest.skip("TODO: RUSTPYTHON; occasionally crash (Exit code -6)")
2069+
@unittest.skip('TODO: RUSTPYTHON; occasionally crash (Exit code -6)')
20922070
@threading_helper.requires_working_threading()
20932071
def test_threaded_weak_value_dict_copy(self):
20942072
# Issue #35615: Weakref keys or values getting GC'ed during dict
@@ -2279,7 +2257,7 @@ def error():
22792257
assert f3.atexit == True
22802258
assert f4.atexit == True
22812259

2282-
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON Windows')
2260+
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON; Windows')
22832261
def test_atexit(self):
22842262
prog = ('from test.test_weakref import FinalizeTestCase;'+
22852263
'FinalizeTestCase.run_in_child()')
@@ -2290,8 +2268,7 @@ def test_atexit(self):
22902268

22912269

22922270
class ModuleTestCase(unittest.TestCase):
2293-
# TODO: RUSTPYTHON
2294-
@unittest.expectedFailure
2271+
@unittest.expectedFailure # TODO: RUSTPYTHON
22952272
def test_names(self):
22962273
for name in ('ReferenceType', 'ProxyType', 'CallableProxyType',
22972274
'WeakMethod', 'WeakSet', 'WeakKeyDictionary', 'WeakValueDictionary'):
@@ -2392,6 +2369,7 @@ def test_names(self):
23922369

23932370
def load_tests(loader, tests, pattern):
23942371
# TODO: RUSTPYTHON
2372+
# The doctest fails
23952373
# tests.addTest(doctest.DocTestSuite())
23962374
return tests
23972375

Lib/token.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""Token constants."""
2-
# Auto-generated by Tools/scripts/generate_token.py
2+
# Auto-generated by Tools/build/generate_token.py
33

4-
__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF']
4+
__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF',
5+
'EXACT_TOKEN_TYPES']
56

67
ENDMARKER = 0
78
NAME = 1
@@ -57,17 +58,20 @@
5758
RARROW = 51
5859
ELLIPSIS = 52
5960
COLONEQUAL = 53
60-
OP = 54
61-
AWAIT = 55
62-
ASYNC = 56
63-
TYPE_IGNORE = 57
64-
TYPE_COMMENT = 58
61+
EXCLAMATION = 54
62+
OP = 55
63+
TYPE_IGNORE = 56
64+
TYPE_COMMENT = 57
65+
SOFT_KEYWORD = 58
66+
FSTRING_START = 59
67+
FSTRING_MIDDLE = 60
68+
FSTRING_END = 61
69+
COMMENT = 62
70+
NL = 63
6571
# These aren't used by the C tokenizer but are needed for tokenize.py
66-
ERRORTOKEN = 59
67-
COMMENT = 60
68-
NL = 61
69-
ENCODING = 62
70-
N_TOKENS = 63
72+
ERRORTOKEN = 64
73+
ENCODING = 65
74+
N_TOKENS = 66
7175
# Special definitions for cooperation with parser
7276
NT_OFFSET = 256
7377

@@ -77,6 +81,7 @@
7781
__all__.extend(tok_name.values())
7882

7983
EXACT_TOKEN_TYPES = {
84+
'!': EXCLAMATION,
8085
'!=': NOTEQUAL,
8186
'%': PERCENT,
8287
'%=': PERCENTEQUAL,

Lib/weakref.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
This module is an implementation of PEP 205:
44
5-
https://www.python.org/dev/peps/pep-0205/
5+
https://peps.python.org/pep-0205/
66
"""
77

88
# Naming convention: Variables named "wr" are weak reference objects;
@@ -33,7 +33,6 @@
3333
"WeakSet", "WeakMethod", "finalize"]
3434

3535

36-
_collections_abc.Set.register(WeakSet)
3736
_collections_abc.MutableSet.register(WeakSet)
3837

3938
class WeakMethod(ref):

0 commit comments

Comments
 (0)