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
9 changes: 9 additions & 0 deletions Lib/test/test_opcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,15 @@ def binary_subscr_str_int():
self.assert_specialized(binary_subscr_str_int, "BINARY_OP_SUBSCR_STR_INT")
self.assert_no_opcode(binary_subscr_str_int, "BINARY_OP")

def binary_subscr_str_int_non_compact():
for _ in range(_testinternalcapi.SPECIALIZATION_THRESHOLD):
a = "바이트코드_특수화"
for idx, expected in enumerate(a):
self.assertEqual(a[idx], expected)

binary_subscr_str_int_non_compact()
self.assert_no_opcode(binary_subscr_str_int_non_compact, "BINARY_OP_SUBSCR_STR_INT")

def binary_subscr_getitems():
class C:
def __init__(self, val):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix unintended bytecode specialization for non-ascii string.
Patch by Donghee Na, Ken Jin and Chris Eibl.
2 changes: 1 addition & 1 deletion Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -2240,7 +2240,7 @@ _Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *in
specialize(instr, BINARY_OP_SUBSCR_TUPLE_INT);
return;
}
if (PyUnicode_CheckExact(lhs)) {
if (PyUnicode_CheckExact(lhs) && PyUnicode_IS_COMPACT_ASCII(lhs)) {
specialize(instr, BINARY_OP_SUBSCR_STR_INT);
return;
}
Expand Down
Loading