[issue46161] `class A(1, 2, 3, **d): pass` gives bad bytecode

Dennis Sweeney report at bugs.python.org
Thu Dec 23 03:53:06 EST 2021


Dennis Sweeney <sweeney.dennis650 at gmail.com> added the comment:

Bisected to here:


13bc13960cc83dbd1cb5701d9a59ac9b9144b205 is the first bad commit
commit 13bc13960cc83dbd1cb5701d9a59ac9b9144b205
Author: Mark Shannon <mark at hotpy.org>
Date:   Thu Jan 23 09:25:17 2020 +0000

    bpo-39320: Handle unpacking of *values in compiler (GH-17984)

    * Add three new bytecodes: LIST_TO_TUPLE, LIST_EXTEND, SET_UPDATE. Use them to implement star unpacking expressions.

    * Remove four bytecodes BUILD_LIST_UNPACK, BUILD_TUPLE_UNPACK, BUILD_SET_UNPACK and  BUILD_TUPLE_UNPACK_WITH_CALL opcodes as they are now unused.

    * Update magic number and dis.rst for new bytecodes.



In debug mode, the following code gives fails a C-level assertion:

d = {'metaclass': type}
for _ in [1]:
    class A(1, 2, 3, **d):
        pass

Assertion failed: b->b_startdepth < 0 || b->b_startdepth == depth, file compile.c, line 6959

----------
nosy: +Dennis Sweeney, Mark.Shannon
title: Incorrect bytecpde compilation for class -> `class A(1, 2, 3, **d): pass` gives bad bytecode
type: compile error -> crash
versions: +Python 3.10, Python 3.11, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46161>
_______________________________________


More information about the Python-bugs-list mailing list