From 106a325ef182ed49783963a67fc4e1488ea7fa88 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 29 Jan 2018 08:47:53 -0500 Subject: [PATCH] Fix Python 2.7 try: try: else: bug --- test/bytecode_2.7/04_try_tryelse.pyc | Bin 0 -> 396 bytes test/simple_source/bug27+/04_try_tryelse.py | 21 ++++++++++++++++++++ uncompyle6/scanners/scanner2.py | 1 + 3 files changed, 22 insertions(+) create mode 100644 test/bytecode_2.7/04_try_tryelse.pyc create mode 100644 test/simple_source/bug27+/04_try_tryelse.py diff --git a/test/bytecode_2.7/04_try_tryelse.pyc b/test/bytecode_2.7/04_try_tryelse.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0606878d47e98f3a44dac2979c8699919c0e00a9 GIT binary patch literal 396 zcmb78!AiqG6nt+}8ym>oA5azqt0H(23FyI73--`bkf6ybflbq9H(;Q>`E~w|Kj6G= z!Lv(d-tJ^}XQH1p`95uy1sxV+W`IjUCD9kr5*wzOR!|C|2p9klfSZCopJ+?;_>$31 zQJ;u?$28x>#LQc!HV&!^>ME$4j22}i0$lrVfiXwqOv~ewY6z~5grt-PNK3Sr-_F=~ z9~xbSv#nNUZxNq66RPU9HMwiLwlL$j?&JFQe0+J6`?ePt>&(Tv_aj)naXznKD|ExX q6A*FA5huX#Fb8VHv6^Tp^DI67;==Afna8+(S2ty6&3%Z(nSKH5GenC3 literal 0 HcmV?d00001 diff --git a/test/simple_source/bug27+/04_try_tryelse.py b/test/simple_source/bug27+/04_try_tryelse.py new file mode 100644 index 00000000..366f3c6f --- /dev/null +++ b/test/simple_source/bug27+/04_try_tryelse.py @@ -0,0 +1,21 @@ +# From 2.7 test_normalize.py +# Bug has to to with finding the end of the tryelse block. I think thrown +# off by the "continue". In instructions the COME_FROM for END_FINALLY +# was at the wrong offset because some sort of "rtarget" was adjust. + +# When control flow is in place this logic in the code will be simplified +def test_main(self, c1): + for line in self: + try: + c1 = 6 + except: + if c1: + try: + c1 = 5 + except: + pass + else: + c1 = 1 + continue + + pass diff --git a/uncompyle6/scanners/scanner2.py b/uncompyle6/scanners/scanner2.py index b501d234..2b29a249 100644 --- a/uncompyle6/scanners/scanner2.py +++ b/uncompyle6/scanners/scanner2.py @@ -816,6 +816,7 @@ class Scanner2(Scanner): rtarget = pre_rtarget else: rtarget = pre_rtarget + pre_rtarget = pre[rtarget] # Does the "jump if" jump beyond a jump op? # That is, we have something like: