-
-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Nested if-while-return fails to decompile in 2.6 #284
Comments
Bugs are bugs. It not about interest so much as having the time to address bugs. There are many more control-flow bugs in 3.7 and 3.8, and those are harder to address. Probably a better use of my time is to address the larger problem handling control flow in more comprehensive way. |
Just noticed that "while 1" also fails to decompile:
Sorry for not reporting it initially, didn't think that "while True" and "while 1" produce different bytecode. |
Want to try fixing yourself? See https://github.com/rocky/python-uncompyle6/wiki/Fixing-Issue-%23150 and https://github.com/rocky/python-uncompyle6/wiki/Fixing-Issue-%23151 and 55783c2 which probably will guide you. |
Looking at your patch it was easy. It could be that this fix can cause problems as I lack compiler background and don't understand the logic by looking at reduction rules. It was your patch that helped, not uncompyle2 tree or uncompile6 traces. Do we need to worry about "Reduce and invalid by check" messages as it looks like they are printed even if decompile is sucessfull? Not sure if I understand correctly the following sentence in Fixing Issue #151
Maybe offset 9 (token 10)? Or am I missing something? To fix the bug #151, you changed 'iflaststmtl' rule, but 'iflaststmtl' is not mentioned anywhere in the grammar reductions. It would be nice if you describe how did you come to 'iflaststmtl'. |
Contragulations! This indeed is the proper fix.
There are not ill side effects that I can see. I'll explain below.
Ok. If you want to add a wiki entry on how you figured this out, that'd be great! Let me explain what's going on here. Previously we got this:
If there were code after that What I'm trying to get across here, is not just that this happens to work in this particular situation, but also that it does model accurately the valid bytecode that is produced. A slight change is that instead of adding that rule, change change the one tht has the As to your questions...
No. In the grammar trace not every reduction that occurs is ultimately used. Only some of them. In some cases, you can't stop an invalid rule from triggering before the reduction. So in the reduction there are additional checks. For example, in a key/value pair in say
I did mean token 9. The text was indeed confusing. I have since updated it. The last piece of work that should be done here is to write a test program that has the |
The following code cannot be decompiled when compiled with Python 2.6.
When compiled with Python 2.7, it is decompiled fine.
Link to the bytecode: https://ufile.io/st8qz15a
I understand this must be a control flow issue. Are you interested in other 2.6 control flow bug reports?
The text was updated successfully, but these errors were encountered: