Skip to content

gh-125038: redundant GET_ITER instructions are removed from genexpr code #126408

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
8 changes: 8 additions & 0 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,14 @@ result back on the stack.
.. versionadded:: 3.5


.. opcode:: CHECK_ITERABLE (is_async)

Checks that ``STACK[-1]`` is iterable or async iterable, depending on
oparg value.

.. versionadded:: 3.14


.. opcode:: TO_BOOL

Implements ``STACK[-1] = bool(STACK[-1])``.
Expand Down
3 changes: 2 additions & 1 deletion Include/internal/pycore_magic_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ Known values:
Python 3.14a1 3607 (Add pseudo instructions JUMP_IF_TRUE/FALSE)
Python 3.14a1 3608 (Add support for slices)
Python 3.14a2 3609 (Add LOAD_SMALL_INT and LOAD_CONST_IMMORTAL instructions, remove RETURN_CONST)
Python 3.14a2 3610 (Add CHECK_ITERABLE)

Python 3.15 will start with 3650

Expand All @@ -274,7 +275,7 @@ PC/launcher.c must also be updated.

*/

#define PYC_MAGIC_NUMBER 3609
#define PYC_MAGIC_NUMBER 3610
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
(little-endian) and then appending b'\r\n'. */
#define PYC_MAGIC_NUMBER_TOKEN \
Expand Down
9 changes: 8 additions & 1 deletion Include/internal/pycore_opcode_metadata.h

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

1 change: 1 addition & 0 deletions Include/internal/pycore_uop_ids.h

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

4 changes: 4 additions & 0 deletions Include/internal/pycore_uop_metadata.h

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

125 changes: 63 additions & 62 deletions Include/opcode_ids.h

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

125 changes: 63 additions & 62 deletions Lib/_opcode_metadata.py

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

6 changes: 6 additions & 0 deletions Lib/test/test_asyncgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,12 @@ async def run():
res = self.loop.run_until_complete(run())
self.assertEqual(res, [i * 2 for i in range(1, 10)])

def test_async_gen_expression_incorrect(self):
err_msg = "'async for' requires an object with " \
"__aiter__ method, got int"
with self.assertRaisesRegex(TypeError, err_msg):
g = (x async for x in 42)

def test_asyncgen_nonstarted_hooks_are_cancellable(self):
# See https://bugs.python.org/issue38013
messages = []
Expand Down
Loading
Loading