Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double return is printed #459

Open
Et7f3 opened this issue May 31, 2023 · 3 comments
Open

Double return is printed #459

Et7f3 opened this issue May 31, 2023 · 3 comments
Labels
Bug Python 3.8 Volunteer wanted Volunteer wanted to fix if a bug or to implement if a new feature. Works on decompyle3

Comments

@Et7f3
Copy link

Et7f3 commented May 31, 2023

Description

double return get printed

How to Reproduce

def main():
  if input() == 0:
    print("0")
    return
  if input() == 1:
    print("1")
  else:
    printf("other")

#458

I used add-test.py with python3.8 with the latest commit on the respective branch

Output Given

# uncompyle6 version 3.9.1.dev0
# Python bytecode version base 3.8.0 (3413)
# Decompiled from: Python 3.8.10 (default, Mar 13 2023, 10:26:41) 
# [GCC 9.4.0]
# Embedded file name: 00_double_return.py
# Compiled at: 2023-05-31 12:07:25
# Size of source mod 2**32: 118 bytes


def main():
    if input() == 0:
        print('0')
        return         return None
    elif input() == 1:
        print('1')
    else:
        printf('other')
# okay decompiling bytecode_3.8/00_double_return.pyc

Expected behavior

def main():
    if input() == 0:
        print('0')
+        return
-        return         return None
    elif input() == 1:
        print('1')
    else:
        printf('other')

Environment

  • Uncompyle6 version: output from uncompyle6 --version uncompyle6 3.9.1.dev0
  • Python version for the version of Python the byte-compiled the file: python -c "import sys; print(sys.version)" where python is the correct CPython or PyPy binary.
    3.8.10 (default, Mar 13 2023, 10:26:41)
    [GCC 9.4.0]
  • OS and Version: Linux codespaces-6db051 5.15.0-1038-azure Revert "Cache pip installation in travis" #45-Ubuntu SMP Mon Apr 24 15:40:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Workarounds

Remove the second run by hand

Priority

I found it while trying to reduce another bug

Additional Context

N/A

@rocky rocky added Bug Volunteer wanted to assist user A volunteer is desired to help the user out with his/her problem. labels May 31, 2023
@rocky
Copy link
Owner

rocky commented May 31, 2023

This does not happen when decompyle3 is used. The obvious fix is to run both with the -gT options and make the grammars, tree, and semantic print actions align.

@rocky rocky added Volunteer wanted Volunteer wanted to fix if a bug or to implement if a new feature. Works on decompyle3 Python 3.8 and removed Volunteer wanted to assist user A volunteer is desired to help the user out with his/her problem. labels May 31, 2023
@Et7f3
Copy link
Author

Et7f3 commented May 31, 2023

While reducing a bug I found 2 others bugs (one that work on decompyle3 and not the second). Do you want I open 2 issues or something else ?

Link to repro (python 3.8):

Can I open draft PR like this issue ?

The priority of these bug is low because the result is pretty good and I can fix those occurrence by hand. Awesome works (hope my tests help you)

@rocky
Copy link
Owner

rocky commented May 31, 2023

Open an issue for every problem - so two (or more) issues please. That way we can track each individually, tag each individually and so on.

PRs are for fixes; the are not a different way of reporting problems. You can attach bytecode and source code in issues.

I can fix those occurrence by hand.

And so as in this issue, that is a "workaround". That's why I have a section for this.

There are way more bugs than there are fixers of bugs. (That in fact is true for every Python decompiler that I am aware of). So feel free and try to fix the problems you report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Python 3.8 Volunteer wanted Volunteer wanted to fix if a bug or to implement if a new feature. Works on decompyle3
Projects
None yet
Development

No branches or pull requests

2 participants