Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

dis._unpack_opargs should handle EXTENDED_ARG_QUICK #92932

Closed
Labels
3.11only security fixes3.12only security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@colesbury

Description

@colesbury

In Python 3.11b0,dis.dis() anddis.get_instructions() will show the "wrong" operand values for instructions prefixed by EXTENDED_ARG_QUICK.

cpython/Lib/dis.py

Lines 591 to 595 ina4460f2

deop=_deoptop(op)
caches=_inline_cache_entries[deop]
ifdeop>=HAVE_ARGUMENT:
arg=code[i+1]|extended_arg
extended_arg= (arg<<8)ifop==EXTENDED_ARGelse0

The bug is that this line only checks forEXTENDED_ARG instructions. It should check for instructions that deoptimize toEXTENDED_ARG (i.e.deop == EXTENDED_ARG).

extended_arg= (arg<<8)ifop==EXTENDED_ARGelse0

To reproduce the issue, consider this snippet adapted from cloudpickle:

importrandomimporttextwrapimportdisnvars=65537+258names= ['g%d'%iforiinrange(1,nvars)]r=random.Random(42)d= {name:r.randrange(100)fornameinnames}# def f(x):#     x = g1, g2, ...code="""def f():    x = {tup}""".format(tup=', '.join(names))exec(textwrap.dedent(code),d,d)f=d['f']dis.dis(f)

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp