Skip to content

gh-131798: JIT: Narrow the return type of _BINARY_OP_SUBSCR_STR_INT to str #132153

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 3 commits into from
Apr 8, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Improve test
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
  • Loading branch information
tomasr8 and brandtbucher authored Apr 8, 2025
commit f6eb00ccc2fc1ce8051e8cb65bef10e76f6111dc
7 changes: 3 additions & 4 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,17 +1648,16 @@ def f(n):

def test_binary_subcsr_str_int_narrows_to_str(self):
def testfunc(n):
x = 0
x = []
s = "foo"
z = ""
for _ in range(n):
y = s[0] # _BINARY_OP_SUBSCR_STR_INT
z = "bar" + y # (_GUARD_TOS_UNICODE) + _BINARY_OP_ADD_UNICODE
x += 1
x.append(z)
return x

res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
self.assertEqual(res, TIER2_THRESHOLD)
self.assertEqual(res, ["barf"] * TIER2_THRESHOLD)
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertIn("_BINARY_OP_SUBSCR_STR_INT", uops)
Expand Down
Loading