Closed treatmesubj closed 2 years ago
In the "honest-come-froms" branch of decompiyle3 this is fixed by this commit. That branch is where I'm trying to address some of the long-standing and pervasive control-flow problems in this approach. And I am afraid that's going to take a while. (But were it done this code would be much more solid)
The commit cited could probably be backported here, but I want someone else to handle that. Are you up for it? Or maybe @x0ret ?
As for the specific problem itself. Python 3.8 removed BREAK_LOOP
and CONTINUE_LOOP
opcodes. in the case of BREAK_LOOP
that is replaced by a POP_BLOCK
, JUMP_ABSOLUTE
around offset 168 shown in the error above.
In general I expect continue
and break
to be problematic in Python 3.8.
Fiinally, let me say that I don't think decompiling 3.8 is all that great. It's just the best thing out there right now. (And I thiink it would be hard to write something better from scratch unless it borrows from the code here.)
For sure way beyond anything I would understand, but I'll definitely take a look out of interest ha. decompile3 honest-come-froms with the new commit definitely fixed that particular break. There probably can't be many 3.8 .pycs yet. PyInstaller master branch doesn't support 3.8 yet either.
At some point I backported this from decompyle3
Description
Expected while true try break except loop. I believe the Python is functionally fine, but I may be stupid, I'm just playing around and experimenting. Looks like the bytecode is right.
How to Reproduce
Used PyInstaller to create an executable with this dummy script, which was the portion of code that seemed to be causing the parsing error in my actual script. Used pyinstxtractor.py to separate out .pyc files from .exe. Added the magic bytes and timestamp at the head of .pyc file. Used uncompyle6 on test.pyc and parsing error was raised. I also tried decompyle3, but found the same error.
Expected Python Script
Bytecode
Console Output
Environment
Windows 10, Python 3.8, uncompyle6 - I pip installed about an hour ago