Skip to content

Missing "While True" #485

Open
Open
@hikali8

Description

@hikali8

Description

"While True" will disappear if a "if" branch is indirectly under it

How to Reproduce

import time

L = ['a', 's']
def thread():
    while True:
        for c in L:
            if c == 'a':
                return
        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:05:50
# Size of source mod 2**32: 157 bytes
import time
L = ["a", "s"]

def thread():
    for c in L:
        if c == "a":
            return             return None
        time.sleep(0.5)

Expected behavior

def thread():
+    while True:
+        for c in L:
+            if c == "a":
+                return
-    for c in L:
-        if c == "a":
-            return             return None
        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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Control FlowProblem has to do with bad control-flow detectionPython 3.8Volunteer wantedVolunteer wanted to fix if a bug or to implement if a new feature.Works on decompyle3

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions