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

Decompiled wrong result with simple if statements #506

Open
DzAvril opened this issue Nov 13, 2024 · 0 comments
Open

Decompiled wrong result with simple if statements #506

DzAvril opened this issue Nov 13, 2024 · 0 comments

Comments

@DzAvril
Copy link

DzAvril commented Nov 13, 2024

Description

I mocked a very simple code block with there if statements. The decompiled result if different from the original code.

How to Reproduce

The original python code.

def foo(a, b, c):
    if a:
        a = 1
    if b:
        b = 2
    if c:
        c = 3

Generate .pyc with following command.
python3 -m py_compile test_uncompy.py
The decompile with uncompy;e6.
uncompyle6 -o ./__pycache__ ./__pycache__/test_uncompy.cpython-36.pyc

The output code is :

# uncompyle6 version 3.9.3.dev0
# Python bytecode version base 3.6 (3379)
# Decompiled from: Python 3.6.9 (default, Mar 10 2023, 16:46:00) 
# [GCC 8.4.0]
# Embedded file name: test_uncompy.py
# Compiled at: 2024-11-13 18:46:46
# Size of source mod 2**32: 89 bytes


def foo(a, b, c):
    if a:
        a = 1
    else:
        if b:
            b = 2
        if c:
            c = 3

If there were more than two if statements than the result is not correct. Please have a look at this issue, thanks very much.

Output Given

# uncompyle6 version 3.9.3.dev0
# Python bytecode version base 3.6 (3379)
# Decompiled from: Python 3.6.9 (default, Mar 10 2023, 16:46:00) 
# [GCC 8.4.0]
# Embedded file name: test_uncompy.py
# Compiled at: 2024-11-13 18:46:46
# Size of source mod 2**32: 89 bytes


def foo(a, b, c):
    if a:
        a = 1
    else:
        if b:
            b = 2
        if c:
            c = 3

Expected behavior

# uncompyle6 version 3.9.3.dev0
# Python bytecode version base 3.6 (3379)
# Decompiled from: Python 3.6.9 (default, Mar 10 2023, 16:46:00) 
# [GCC 8.4.0]
# Embedded file name: test_uncompy.py
# Compiled at: 2024-11-13 18:46:46
# Size of source mod 2**32: 89 bytes


def foo(a, b, c):
    if a:
        a = 1
    if b:
        b = 2
    if c:
        c = 3

Environment

uncompyle6, version 3.9.3.dev0
pydisasm, version 6.1.0
python 3.6.13 |Anaconda, Inc.| (default, Jun  4 2021, 14:25:59)
6.5.0-14-generic #14~22.04.1-Ubuntu

Workarounds

Priority

Additional Context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants