Thanks to visit codestin.com
Credit goes to github.com

Skip to content

uncompyle6.main.decompile has incorrect type annotation for bytecode_version #391

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

Closed
SuperStormer opened this issue Apr 21, 2022 · 0 comments

Comments

@SuperStormer
Copy link

SuperStormer commented Apr 21, 2022

Description

bytecode_version is annotated as a str, but decompile in reality only accepts tuples.

How to Reproduce

>>> from uncompyle6.main import decompile
>>> def a():print("hello world")
...
>>> decompile(a.__code__,"3.8")
# uncompyle6 version 3.9.0a1
# Python bytecode version base 3...8
# Decompiled from: Python 3.9.12 (main, Mar 24 2022, 13:02:21)
# [GCC 11.2.0]
# Embedded file name: <stdin>
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/redacted/.local/lib/python3.9/site-packages/uncompyle6/main.py", line 143, in decompile
    deparsed = deparse_fn(
  File "/home/redacted/.local/lib/python3.9/site-packages/uncompyle6/semantics/pysource.py", line 1471, in code_deparse
    deparsed = walker(
  File "/home/redacted/.local/lib/python3.9/site-packages/uncompyle6/semantics/pysource.py", line 314, in __init__
    customize_for_version(self, is_pypy, version)
  File "/home/redacted/.local/lib/python3.9/site-packages/uncompyle6/semantics/customize.py", line 112, in customize_for_version
    if version >= (3, 0):
TypeError: '>=' not supported between instances of 'str' and 'tuple'

Expected behavior

Either strings should be accepted, or the type annotation be changed to tuple[int].

Environment

uncompyle6 3.9.0a1

(I installed the latest version from github)

3.9.12 (main, Mar 24 2022, 13:02:21)
[GCC 11.2.0]

Workarounds

Pass tuple(map(int,version.split("."))) instead

@rocky rocky closed this as completed in 464801b Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant