summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-06-03 03:02:55 (GMT)
committerGitHub <noreply@github.com>2022-06-03 03:02:55 (GMT)
commite798f698e51727d1e6596b4780e876e2b5db7528 (patch)
treee1582da95bf2f805a4f6bd013b8c888f70247405
parent376d53771d4c109876fd3d002fb8aa5e2c8dec89 (diff)
downloadcpython-e798f698e51727d1e6596b4780e876e2b5db7528.zip
cpython-e798f698e51727d1e6596b4780e876e2b5db7528.tar.gz
cpython-e798f698e51727d1e6596b4780e876e2b5db7528.tar.bz2
gh-92932: dis._unpack_opargs should handle EXTENDED_ARG_QUICK (gh-92945)
(cherry picked from commit b013804134b07894205b06744628f6b25b879d85) Co-authored-by: Dong-hee Na <donghee.na@python.org>
-rw-r--r--Lib/dis.py2
-rw-r--r--Lib/test/test_dis.py21
-rw-r--r--Misc/NEWS.d/next/Library/2022-05-19-17-49-58.gh-issue-92932.o2peTh.rst3
3 files changed, 25 insertions, 1 deletions
diff --git a/Lib/dis.py b/Lib/dis.py
index 0460131..5a5ee8d 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -592,7 +592,7 @@ def _unpack_opargs(code):
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
+ extended_arg = (arg << 8) if deop == EXTENDED_ARG else 0
# The oparg is stored as a signed integer
# If the value exceeds its upper limit, it will overflow and wrap
# to a negative integer
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index af736d6..edcac8e 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -633,6 +633,22 @@ dis_loop_test_quickened_code = """\
loop_test.__code__.co_firstlineno + 2,
loop_test.__code__.co_firstlineno + 1,)
+def extended_arg_quick():
+ *_, _ = ...
+
+dis_extended_arg_quick_code = """\
+%3d 0 RESUME 0
+
+%3d 2 LOAD_CONST 1 (Ellipsis)
+ 4 EXTENDED_ARG_QUICK 1
+ 6 UNPACK_EX 256
+ 8 STORE_FAST 0 (_)
+ 10 STORE_FAST 0 (_)
+ 12 LOAD_CONST 0 (None)
+ 14 RETURN_VALUE
+"""% (extended_arg_quick.__code__.co_firstlineno,
+ extended_arg_quick.__code__.co_firstlineno + 1,)
+
QUICKENING_WARMUP_DELAY = 8
class DisTestBase(unittest.TestCase):
@@ -1011,6 +1027,11 @@ class DisTests(DisTestBase):
got = self.get_disassembly(loop_test, adaptive=True)
self.do_disassembly_compare(got, dis_loop_test_quickened_code, True)
+ @cpython_only
+ def test_extended_arg_quick(self):
+ got = self.get_disassembly(extended_arg_quick)
+ self.do_disassembly_compare(got, dis_extended_arg_quick_code, True)
+
def get_cached_values(self, quickened, adaptive):
def f():
l = []
diff --git a/Misc/NEWS.d/next/Library/2022-05-19-17-49-58.gh-issue-92932.o2peTh.rst b/Misc/NEWS.d/next/Library/2022-05-19-17-49-58.gh-issue-92932.o2peTh.rst
new file mode 100644
index 0000000..cb76ac5
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-05-19-17-49-58.gh-issue-92932.o2peTh.rst
@@ -0,0 +1,3 @@
+Now :func:`~dis.dis` and :func:`~dis.get_instructions` handle operand values
+for instructions prefixed by ``EXTENDED_ARG_QUICK``.
+Patch by Sam Gross and Dong-hee Na.