Skip to content

gh-115999: Update test_opcache to test with nested method #128166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 23, 2024
Merged
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
18 changes: 8 additions & 10 deletions Lib/test/test_opcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def assert_races_do_not_crash(
for writer in writers:
writer.join()

@requires_specialization
@requires_specialization_ft
def test_binary_subscr_getitem(self):
def get_items():
class C:
Expand Down Expand Up @@ -1242,14 +1242,6 @@ def f(o, n):
f(test_obj, 1)
self.assertEqual(test_obj.b, 0)

# gh-127274: BINARY_SUBSCR_GETITEM will only cache __getitem__ methods that
# are deferred. We only defer functions defined at the top-level.
class CGetItem:
def __init__(self, val):
self.val = val
def __getitem__(self, item):
return self.val


class TestSpecializer(TestBase):

Expand Down Expand Up @@ -1592,7 +1584,13 @@ def binary_subscr_str_int():
self.assert_no_opcode(binary_subscr_str_int, "BINARY_SUBSCR")

def binary_subscr_getitems():
items = [CGetItem(i) for i in range(100)]
class C:
def __init__(self, val):
self.val = val
def __getitem__(self, item):
return self.val

items = [C(i) for i in range(100)]
for i in range(100):
self.assertEqual(items[i][i], i)

Expand Down
Loading