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
69 changes: 69 additions & 0 deletions Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,75 @@
hascompare = [opmap["COMPARE_OP"]]

_cache_format = {
"LOAD_GLOBAL": {
"counter": 1,
"index": 1,
"module_keys_version": 1,
"builtin_keys_version": 1,
},
"BINARY_OP": {
"counter": 1,
"descr": 4,
},
"UNPACK_SEQUENCE": {
"counter": 1,
},
"COMPARE_OP": {
"counter": 1,
},
"CONTAINS_OP": {
"counter": 1,
},
"FOR_ITER": {
"counter": 1,
},
"LOAD_SUPER_ATTR": {
"counter": 1,
},
"LOAD_ATTR": {
"counter": 1,
"version": 2,
"keys_version": 2,
"descr": 4,
},
"STORE_ATTR": {
"counter": 1,
"version": 2,
"index": 1,
},
"CALL": {
"counter": 1,
"func_version": 2,
},
"CALL_KW": {
"counter": 1,
"func_version": 2,
},
"STORE_SUBSCR": {
"counter": 1,
},
"SEND": {
"counter": 1,
},
"JUMP_BACKWARD": {
"counter": 1,
},
"TO_BOOL": {
"counter": 1,
"version": 2,
},
"POP_JUMP_IF_TRUE": {
"counter": 1,
},
"POP_JUMP_IF_FALSE": {
"counter": 1,
},
"POP_JUMP_IF_NONE": {
"counter": 1,
},
"POP_JUMP_IF_NOT_NONE": {
"counter": 1,
},
}

_inline_cache_entries = {
Expand Down
3 changes: 0 additions & 3 deletions Lib/test/test_dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2236,7 +2236,6 @@ def f(opcode, oparg, offset, *init_args):
def get_instructions(self, code):
return dis._get_instructions_bytes(code)

@unittest.expectedFailure # TODO: RUSTPYTHON; no inline caches
def test_start_offset(self):
# When no extended args are present,
# start_offset should be equal to offset
Expand Down Expand Up @@ -2289,7 +2288,6 @@ def last_item(iterable):
self.assertEqual(14, instructions[6].offset)
self.assertEqual(8, instructions[6].start_offset)

@unittest.expectedFailure # TODO: RUSTPYTHON; no inline caches
def test_cache_offset_and_end_offset(self):
code = bytes([
opcode.opmap["LOAD_GLOBAL"], 0x01,
Expand Down Expand Up @@ -2588,7 +2586,6 @@ def f():
with contextlib.redirect_stderr(io.StringIO()):
_ = self.invoke_dis('--unknown')

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_show_cache(self):
# test 'python -m dis -C/--show-caches'
source = 'print()'
Expand Down
7 changes: 0 additions & 7 deletions Lib/test/test_inspect/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,6 @@ def function():
_global_ref = object()
class TestGetClosureVars(unittest.TestCase):

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Closu[132 chars]={'print': <built-in function print>}, unbound=set()) != Closu[132 chars]={'print': <built-in function print>}, unbound={'unbound_ref'})
def test_name_resolution(self):
# Basic test of the 4 different resolution mechanisms
def f(nonlocal_ref):
Expand All @@ -2036,7 +2035,6 @@ def g(local_ref):
builtin_vars, unbound_names)
self.assertEqual(inspect.getclosurevars(f(_arg)), expected)

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Closu[132 chars]={'print': <built-in function print>}, unbound=set()) != Closu[132 chars]={'print': <built-in function print>}, unbound={'unbound_ref'})
def test_generator_closure(self):
def f(nonlocal_ref):
def g(local_ref):
Expand All @@ -2052,7 +2050,6 @@ def g(local_ref):
builtin_vars, unbound_names)
self.assertEqual(inspect.getclosurevars(f(_arg)), expected)

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Closu[132 chars]={'print': <built-in function print>}, unbound=set()) != Closu[132 chars]={'print': <built-in function print>}, unbound={'unbound_ref'})
def test_method_closure(self):
class C:
def f(self, nonlocal_ref):
Expand All @@ -2068,7 +2065,6 @@ def g(local_ref):
builtin_vars, unbound_names)
self.assertEqual(inspect.getclosurevars(C().f(_arg)), expected)

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Closu[139 chars]als={}, builtins={'print': <built-in function [18 chars]et()) != Closu[139 chars]als={'_global_ref': <object object at 0xa4ffee[73 chars]ef'})
def test_attribute_same_name_as_global_var(self):
class C:
_global_ref = object()
Expand Down Expand Up @@ -2138,21 +2134,18 @@ def _private_globals(self):
exec(code, ns)
return ns["f"], ns

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Closu[34 chars]uiltins={'print': <built-in function print>}, unbound=set()) != Closu[34 chars]uiltins={'print': <built-in function print>}, unbound={'path'})
def test_builtins_fallback(self):
f, ns = self._private_globals()
ns.pop("__builtins__", None)
expected = inspect.ClosureVars({}, {}, {"print":print}, {"path"})
self.assertEqual(inspect.getclosurevars(f), expected)

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: ClosureVars(nonlocals={}, globals={}, builtins={}, unbound={'print'}) != ClosureVars(nonlocals={}, globals={}, builtins={'path': 1}, unbound={'print'})
def test_builtins_as_dict(self):
f, ns = self._private_globals()
ns["__builtins__"] = {"path":1}
expected = inspect.ClosureVars({}, {}, {"path":1}, {"print"})
self.assertEqual(inspect.getclosurevars(f), expected)

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Closu[38 chars]ins={}, unbound={'print'}) != Closu[38 chars]ins={'path': <module 'posixpath' from '/Users/[79 chars]nt'})
def test_builtins_as_module(self):
f, ns = self._private_globals()
ns["__builtins__"] = os
Expand Down
4 changes: 0 additions & 4 deletions Lib/test/test_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,6 @@ def func1():
('instruction', 'func1', 16),
('line', 'get_events', 11)])

@unittest.expectedFailure # TODO: RUSTPYTHON; - instruction offsets differ from CPython
def test_c_call(self):

def func2():
Expand Down Expand Up @@ -1672,7 +1671,6 @@ def func():
('return', 'func', None),
('line', 'get_events', 11)])

@unittest.expectedFailure # TODO: RUSTPYTHON; - bytecode layout differs from CPython
def test_while_offset_consistency(self):

def foo(n=0):
Expand All @@ -1690,7 +1688,6 @@ def foo(n=0):
in_loop,
exit_loop])

@unittest.expectedFailure # TODO: RUSTPYTHON; - bytecode layout differs from CPython
def test_async_for(self):

def func():
Expand Down Expand Up @@ -2126,7 +2123,6 @@ def test_get_local_events_uninitialized(self):

class TestRegressions(MonitoringTestBase, unittest.TestCase):

@unittest.expectedFailure # TODO: RUSTPYTHON; + inner
def test_105162(self):
caught = None

Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_peepholer.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ def f():
self.check_jump_targets(f)
self.check_lnotab(f)

@unittest.expectedFailure # TODO: RUSTPYTHON; KeyError: 44
def test_elim_jump_to_uncond_jump3(self):
# Intentionally use two-line expressions to test issue37213.
# POP_JUMP_IF_FALSE to POP_JUMP_IF_FALSE --> POP_JUMP_IF_FALSE to non-jump
Expand Down
Loading
Loading