From 605721c99525e5ed394377c5a96817aefa81396c Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 7 May 2017 09:10:05 -0400 Subject: [PATCH] Python 3.x control-flow bug... "pass" statement inside "while True" --- test/bytecode_3.1/12_if_while_true_pass.pyc | Bin 0 -> 447 bytes test/bytecode_3.3/12_if_while_true_pass.pyc | Bin 0 -> 468 bytes .../looping/12_if_while_true_pass.py | 14 ++++++++++++++ uncompyle6/scanners/scanner3.py | 6 +----- 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 test/bytecode_3.1/12_if_while_true_pass.pyc create mode 100644 test/bytecode_3.3/12_if_while_true_pass.pyc create mode 100644 test/simple_source/looping/12_if_while_true_pass.py diff --git a/test/bytecode_3.1/12_if_while_true_pass.pyc b/test/bytecode_3.1/12_if_while_true_pass.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0adaa83ab583ef536f285cc54e145084a519576c GIT binary patch literal 447 zcmbVG!Ab)$6r42LwYA0Dp1cZ+hb?**5%uJuB0ZD}vMjr?4Q{(>vcVSGTR+_Q(u(5I z2Q!(x$;+GPUcW2P&n5+al^}gbaDAc@*a5F31V%}VI)xS#N8ia(6QML|!vPv0rgk^*=EgmJjVyHQgj+nYc2?4?JY)t(z zaZ`V&h3DrcZ)U#p-D=iG?FXm>pAtDeHl2}3<^DkS1SUu(=;>i_@% literal 0 HcmV?d00001 diff --git a/test/simple_source/looping/12_if_while_true_pass.py b/test/simple_source/looping/12_if_while_true_pass.py new file mode 100644 index 00000000..cf3bd1c5 --- /dev/null +++ b/test/simple_source/looping/12_if_while_true_pass.py @@ -0,0 +1,14 @@ +# Python 3.3 pyclbr.py +# Note that Python 3 adds a lot of unecessary "continues" +# and puts that in for "pass" +def _readmodule(g, token, path): + for tokentype in g: + if g: + while True: + if token: + token = 1 + elif token: + pass + elif tokentype: + token = 7 + token = 10 diff --git a/uncompyle6/scanners/scanner3.py b/uncompyle6/scanners/scanner3.py index 31953266..e347bb6b 100644 --- a/uncompyle6/scanners/scanner3.py +++ b/uncompyle6/scanners/scanner3.py @@ -338,11 +338,7 @@ class Scanner3(Scanner): (next_opname not in ('END_FINALLY', 'POP_BLOCK', # Python 3.0 only uses POP_TOP 'POP_TOP'))): - if (self.version >= 3.4 or - (inst.offset not in self.not_continue) or - (tokens[-1].type == 'RETURN_VALUE')): - opname = 'CONTINUE' - pass + opname = 'CONTINUE' else: opname = 'JUMP_BACK' # FIXME: this is a hack to catch stuff like: