-
- Notifications
You must be signed in to change notification settings - Fork 33.1k
Closed
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
In Python 3.11b0, dis.dis()
and dis.get_instructions()
will show the "wrong" operand values for instructions prefixed by EXTENDED_ARG_QUICK.
Lines 591 to 595 in a4460f2
deop = _deoptop(op) | |
caches = _inline_cache_entries[deop] | |
if deop >= HAVE_ARGUMENT: | |
arg = code[i+1] | extended_arg | |
extended_arg = (arg << 8) if op == EXTENDED_ARG else 0 |
The bug is that this line only checks for EXTENDED_ARG
instructions. It should check for instructions that deoptimize to EXTENDED_ARG
(i.e. deop == EXTENDED_ARG
).
Line 595 in a4460f2
extended_arg = (arg << 8) if op == EXTENDED_ARG else 0 |
To reproduce the issue, consider this snippet adapted from cloudpickle:
import random import textwrap import dis nvars = 65537 + 258 names = ['g%d' % i for i in range(1, nvars)] r = random.Random(42) d = {name: r.randrange(100) for name in names} # 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
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error