We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e9d9494 commit 57faf34Copy full SHA for 57faf34
3 files changed
Lib/test/test__opcode.py
@@ -15,6 +15,21 @@ def test_stack_effect(self):
15
self.assertRaises(ValueError, _opcode.stack_effect, 30000)
16
self.assertRaises(ValueError, _opcode.stack_effect, dis.opmap['BUILD_SLICE'])
17
self.assertRaises(ValueError, _opcode.stack_effect, dis.opmap['POP_TOP'], 0)
18
+ # All defined opcodes
19
+ for name, code in dis.opmap.items():
20
+ with self.subTest(opname=name):
21
+ if code < dis.HAVE_ARGUMENT:
22
+ _opcode.stack_effect(code)
23
+ self.assertRaises(ValueError, _opcode.stack_effect, code, 0)
24
+ else:
25
+ _opcode.stack_effect(code, 0)
26
+ self.assertRaises(ValueError, _opcode.stack_effect, code)
27
+ # All not defined opcodes
28
+ for code in set(range(256)) - set(dis.opmap.values()):
29
+ with self.subTest(opcode=code):
30
31
32
+
33
34
if __name__ == "__main__":
35
unittest.main()
Misc/NEWS.d/next/Library/2018-04-22-20-13-21.bpo-33334.19UMOC.rst
@@ -0,0 +1,2 @@
1
+:func:`dis.stack_effect` now supports all defined opcodes including NOP and
2
+EXTENDED_ARG.
Python/compile.c
@@ -859,6 +859,10 @@ static int
859
stack_effect(int opcode, int oparg, int jump)
860
{
861
switch (opcode) {
862
+ case NOP:
863
+ case EXTENDED_ARG:
864
+ return 0;
865
866
/* Stack manipulation */
867
case POP_TOP:
868
return -1;
0 commit comments