Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ def _acquire_release(lock, timeout, l=None, n=1):
for _ in range(n):
lock.release()

@unittest.skip("TODO: RUSTPYTHON; flaky test")
@unittest.expectedFailureIf(sys.platform == "darwin", "TODO: RUSTPYTHON")
def test_repr_rlock(self):
if self.TYPE != 'processes':
self.skipTest('test not appropriate for {}'.format(self.TYPE))
Expand Down
74 changes: 26 additions & 48 deletions Lib/test/test_weakref.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,7 @@ def test_ref_reuse(self):
self.assertEqual(weakref.getweakrefcount(o), 1,
"wrong weak ref count for object after deleting proxy")

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_proxy_reuse(self):
o = C()
proxy1 = weakref.proxy(o)
Expand Down Expand Up @@ -338,8 +337,7 @@ def __bytes__(self):
self.assertIn("__bytes__", dir(weakref.proxy(instance)))
self.assertEqual(bytes(weakref.proxy(instance)), b"bytes")

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_proxy_index(self):
class C:
def __index__(self):
Expand All @@ -348,8 +346,7 @@ def __index__(self):
p = weakref.proxy(o)
self.assertEqual(operator.index(p), 10)

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_proxy_div(self):
class C:
def __floordiv__(self, other):
Expand All @@ -362,8 +359,7 @@ def __ifloordiv__(self, other):
p //= 5
self.assertEqual(p, 21)

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_proxy_matmul(self):
class C:
def __matmul__(self, other):
Expand All @@ -387,13 +383,11 @@ def __imatmul__(self, other):
# was not honored, and was broken in different ways for
# PyWeakref_NewRef() and PyWeakref_NewProxy(). (Two tests.)

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_shared_ref_without_callback(self):
self.check_shared_without_callback(weakref.ref)

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_shared_proxy_without_callback(self):
self.check_shared_without_callback(weakref.proxy)

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

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_callable_proxy(self):
o = Callable()
ref1 = weakref.proxy(o)
Expand Down Expand Up @@ -511,8 +504,7 @@ def __iter__(self):
# Calls proxy.__next__
self.assertEqual(list(weak_it), [4, 5, 6])

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

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_newstyle_number_ops(self):
class F(float):
pass
Expand Down Expand Up @@ -770,8 +761,7 @@ class D:
del c1, c2, C, D
gc.collect()

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
@suppress_immortalization()
def test_callback_in_cycle_resurrection(self):
import gc
Expand Down Expand Up @@ -819,8 +809,7 @@ def C_went_away(ignore):
gc.collect()
self.assertEqual(alist, [])

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_callbacks_on_callback(self):
import gc

Expand Down Expand Up @@ -859,13 +848,11 @@ def cb(self, ignore):
gc.collect()
self.assertEqual(alist, [])

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_gc_during_ref_creation(self):
self.check_gc_during_creation(weakref.ref)

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_gc_during_proxy_creation(self):
self.check_gc_during_creation(weakref.proxy)

Expand Down Expand Up @@ -1016,8 +1003,7 @@ def cb(wparent):
del root
gc.collect()

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_callback_attribute(self):
x = Object(1)
callback = lambda ref: None
Expand All @@ -1027,8 +1013,7 @@ def test_callback_attribute(self):
ref2 = weakref.ref(x)
self.assertIsNone(ref2.__callback__)

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_callback_attribute_after_deletion(self):
x = Object(1)
ref = weakref.ref(x, self.callback)
Expand Down Expand Up @@ -1080,8 +1065,7 @@ def callback(obj):

class SubclassableWeakrefTestCase(TestBase):

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_subclass_refs(self):
class MyRef(weakref.ref):
def __init__(self, ob, callback=None, value=42):
Expand All @@ -1100,8 +1084,7 @@ def __call__(self):
self.assertIsNone(mr())
self.assertTrue(mr.called)

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_subclass_refs_dont_replace_standard_refs(self):
class MyRef(weakref.ref):
pass
Expand Down Expand Up @@ -1353,13 +1336,11 @@ def check_len_cycles(self, dict_type, cons):
self.assertIn(n1, (0, 1))
self.assertEqual(n2, 0)

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_weak_keyed_len_cycles(self):
self.check_len_cycles(weakref.WeakKeyDictionary, lambda k: (k, 1))

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_weak_valued_len_cycles(self):
self.check_len_cycles(weakref.WeakValueDictionary, lambda k: (1, k))

Expand Down Expand Up @@ -1387,13 +1368,11 @@ def check_len_race(self, dict_type, cons):
self.assertGreaterEqual(n2, 0)
self.assertLessEqual(n2, n1)

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_weak_keyed_len_race(self):
self.check_len_race(weakref.WeakKeyDictionary, lambda k: (k, 1))

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_weak_valued_len_race(self):
self.check_len_race(weakref.WeakValueDictionary, lambda k: (1, k))

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

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_weak_keyed_bad_delitem(self):
d = weakref.WeakKeyDictionary()
o = Object('1')
Expand Down Expand Up @@ -2088,7 +2066,7 @@ def test_threaded_weak_key_dict_deepcopy(self):
# copying should not result in a crash.
self.check_threaded_weak_dict_copy(weakref.WeakKeyDictionary, True)

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

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


class ModuleTestCase(unittest.TestCase):
# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_names(self):
for name in ('ReferenceType', 'ProxyType', 'CallableProxyType',
'WeakMethod', 'WeakSet', 'WeakKeyDictionary', 'WeakValueDictionary'):
Expand Down Expand Up @@ -2392,6 +2369,7 @@ def test_names(self):

def load_tests(loader, tests, pattern):
# TODO: RUSTPYTHON
# The doctest fails
# tests.addTest(doctest.DocTestSuite())
return tests

Expand Down
29 changes: 17 additions & 12 deletions Lib/token.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Token constants."""
# Auto-generated by Tools/scripts/generate_token.py
# Auto-generated by Tools/build/generate_token.py

__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF']
__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF',
'EXACT_TOKEN_TYPES']

ENDMARKER = 0
NAME = 1
Expand Down Expand Up @@ -57,17 +58,20 @@
RARROW = 51
ELLIPSIS = 52
COLONEQUAL = 53
OP = 54
AWAIT = 55
ASYNC = 56
TYPE_IGNORE = 57
TYPE_COMMENT = 58
EXCLAMATION = 54
OP = 55
TYPE_IGNORE = 56
TYPE_COMMENT = 57
SOFT_KEYWORD = 58
FSTRING_START = 59
FSTRING_MIDDLE = 60
FSTRING_END = 61
COMMENT = 62
NL = 63
# These aren't used by the C tokenizer but are needed for tokenize.py
ERRORTOKEN = 59
COMMENT = 60
NL = 61
ENCODING = 62
N_TOKENS = 63
ERRORTOKEN = 64
ENCODING = 65
N_TOKENS = 66
# Special definitions for cooperation with parser
NT_OFFSET = 256

Expand All @@ -77,6 +81,7 @@
__all__.extend(tok_name.values())

EXACT_TOKEN_TYPES = {
'!': EXCLAMATION,
'!=': NOTEQUAL,
'%': PERCENT,
'%=': PERCENTEQUAL,
Expand Down
3 changes: 1 addition & 2 deletions Lib/weakref.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This module is an implementation of PEP 205:

https://www.python.org/dev/peps/pep-0205/
https://peps.python.org/pep-0205/
"""

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


_collections_abc.Set.register(WeakSet)
_collections_abc.MutableSet.register(WeakSet)

class WeakMethod(ref):
Expand Down
Loading