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

Redundant "else:" #486

Open
hikali8 opened this issue Mar 5, 2024 · 0 comments
Open

Redundant "else:" #486

hikali8 opened this issue Mar 5, 2024 · 0 comments
Labels
control flow Python 3.8 volunteer wanted Volunteer wanted to fix if a bug or to implement if a new feature. Works on decompyle3

Comments

@hikali8
Copy link

hikali8 commented Mar 5, 2024

Description

a redundant "else:" will be printed

How to Reproduce

import time

L = ["a", "s"]
def thread():
    for c in L:
        if c == 'a':
            print(c)
            break
    time.sleep(0.5)

Output Given

# uncompyle6 version 3.9.1.dev0
# Python bytecode version base 3.8.0 (3413)
# Decompiled from: Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
# Embedded file name: simple.py
# Compiled at: 2024-03-05 23:58:49
# Size of source mod 2**32: 145 bytes
import time
L = ["a", "s"]

def thread():
    for c in L:
        if c == "a":
            print(c)
            break
    else:
        time.sleep(0.5)

Expected behavior

def thread():
    for c in L:
        if c == "a":
            print(c)
            break
+    time.sleep(0.5)
-    else:
-        time.sleep(0.5)

Environment

  • Uncompyle6 version: output from uncompyle6 --version uncompyle6 3.9.1.dev0
  • xdis version: output from pydisasm --version pydisasm, version 6.1.0.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 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
  • OS and Version: Windows 11 (23H2)
@rocky rocky added control flow volunteer wanted Volunteer wanted to fix if a bug or to implement if a new feature. Python 3.8 Works on decompyle3 labels Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
control flow 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