Skip to content

Commit

Permalink
pythongh-125038: some changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
efimov-mikhail committed Nov 7, 2024
1 parent 5109efa commit b9e2b38
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Adds :opcode:`CHECK_ITERABLE` instruction. It checks that TOS is iterable or
async iterable. Redundant ``GET_ITER`` and ``GET_AITER`` instructions are
removed from generator expression code. Patch by Mikhail Efimov.
Adds :opcode:`CHECK_ITERABLE` instruction. It checks that top of the stack
is iterable or async iterable. Redundant ``GET_ITER`` and ``GET_AITER``
instructions are removed from generator expression code.
Patch by Mikhail Efimov.
14 changes: 7 additions & 7 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -5032,13 +5032,11 @@ dummy_func(
PyTypeObject *type = Py_TYPE(iterable);
if (oparg == 0) {
// Sync case, similar to GET_ITER
if (type->tp_iter == NULL) {
if (!PySequence_Check(iterable)) {
PyErr_Format(PyExc_TypeError,
"'%.200s' object is not iterable",
type->tp_name);
ERROR_NO_POP();
}
if (type->tp_iter == NULL || !PySequence_Check(iterable)) {
PyErr_Format(PyExc_TypeError,
"'%.200s' object is not iterable",
type->tp_name);
ERROR_NO_POP();
}
} else if (oparg == 1) {
// Async case, similar to GET_AITER
Expand All @@ -5049,6 +5047,8 @@ dummy_func(
type->tp_name);
ERROR_NO_POP();
}
} else {
Py_UNREACHABLE();
}
}

Expand Down
26 changes: 11 additions & 15 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 11 additions & 15 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b9e2b38

Please sign in to comment.