Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Error of "if if else" expr sequence

オープン
#351 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python

調査の方向性

Reproduce the issue from test.py by compiling it with Python 3.8.5 or 3.6.9, then run uncompyle6 test.pyc > test_dec.py and compare the control-flow output with the original. The work is done when separate if statements with a following else decompile without changing their behavior.

索引モデルが issue の本文から書いたものです。

説明

Control Flow Works on decompyle3

Description

Error of "if if else" expr sequence

How to Reproduce

here is the source code test.py:

a = 1
b = 1
if a:
    print("a")
if b:
    print("b")
else:
    print("else")

then compile it with:

python3 -m compileall -b test.py

and decompile it

uncompyle6 test.pyc >test_dec.py

the output is:

a = 1
b = 1
if a:
    print('a')
elif b:
    print('b')
else:
    print('else')

the decompiled code is quite different from the origin code
if run the code, it will print:

$ python3 test.py
a
b
$ python3 test_dec.py
a

Expected behavior

expected decompiled code may look like this:

a = 1
b = 1
if a:
    print("a")
if b:
    print("b")
else:
    print("else")

Environment

this bug can be repeated in such environments:

Ubuntu 20.04
Python 3.8.5 (default, May 27 2021, 13:30:53) [GCC 9.3.0] on linux
uncompyle6 3.7.4 from pip

or

Ubuntu 18.04
Python 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0]
uncompyle6 3.7.4 from pip

Additional Environment or Context

This bug does not exist in decompile3, but decompile3 cannot handler python3.6 bytecode.

主要言語
Python
スター
4.3k
フォーク
465
平均マージ
4日 11時間
マージ済み PR(30日)
3

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rocky/python-uncompyle6 のほかの issue

rocky/python-uncompyle6 の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。