Skip to content

Commit f8b7e4e

Browse files
committed
Fix unique tuple unpacking checks
1 parent 7aeac0e commit f8b7e4e

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

Python/bytecodes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,7 @@ dummy_func(
16751675
PyObject *seq_o = PyStackRef_AsPyObjectBorrow(seq);
16761676
assert(PyTuple_CheckExact(seq_o));
16771677
DEOPT_IF(PyTuple_GET_SIZE(seq_o) != oparg);
1678+
DEOPT_IF(!_PyObject_IsUniquelyReferenced(seq_o));
16781679
STAT_INC(UNPACK_SEQUENCE, hit);
16791680
PyObject **items = _PyTuple_ITEMS(seq_o);
16801681
for (int i = oparg; --i >= 0; ) {

Python/executor_cases.c.h

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer_bytecodes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,8 +1350,8 @@ dummy_func(void) {
13501350
}
13511351

13521352
op(_UNPACK_SEQUENCE_TUPLE, (seq -- values[oparg])) {
1353-
if (PyJitRef_IsUnique(seq)) {
1354-
REPLACE_OP((this_instr), _UNPACK_SEQUENCE_UNIQUE_TUPLE, oparg, 0);
1353+
if (PyJitRef_IsUnique(seq) && sym_tuple_length(seq) == oparg) {
1354+
ADD_OP(_UNPACK_SEQUENCE_UNIQUE_TUPLE, oparg, 0);
13551355
}
13561356
for (int i = 0; i < oparg; i++) {
13571357
values[i] = sym_tuple_getitem(ctx, seq, oparg - i - 1);

Python/optimizer_cases.c.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)