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

Bugs from uncompyle6's 3.3 bytecode test suite #1

Open
rocky opened this issue Feb 18, 2018 · 0 comments
Open

Bugs from uncompyle6's 3.3 bytecode test suite #1

rocky opened this issue Feb 18, 2018 · 0 comments

Comments

@rocky
Copy link

rocky commented Feb 18, 2018

Even if these bugs are not likely to ever be addressed, there's value in recording what kinds of bugs are there.

These probably should be broken out into one issue per bug, and some might turn out to be duplicates, but since there's little chance of any getting fixed, I'm reducing the reporting effort.

# In Python 3.3+ this uses grammar rule
# compare_chained2 ::= expr COMPARE_OP RETURN_VALUE

# Seen in Python 3.3 ipaddress.py

def _is_valid_netmask(netmask):
    return 0 <= netmask <= 10

# There were also bugs in 2.6- involving the use of "or" twice in its "or"
# detections

# See in 2.6.9 quopri.py ishex():
'0' <= __file__ <= '9' or 'a' <= __file__ <= 'f' or 'A' <= __file__ <= 'F'
======= python-uncompyle6/test/bytecode_3.3/01_triple_compare.pyc =========
Traceback (most recent call last):
  File "unpyc3.py", line 2021, in <module>
    print(decompile(sys.argv[1]))
  File "unpyc3.py", line 1195, in __str__
    self.display(istr)
  File "unpyc3.py", line 1201, in display
    stmt.display(indent)
  File "unpyc3.py", line 1044, in display
    self.display_undecorated(indent)
  File "unpyc3.py", line 1068, in display_undecorated
    self.code.get_suite().display(indent + 1)
  File "unpyc3.py", line 302, in get_suite
    dec.run()
  File "unpyc3.py", line 1260, in run
    new_addr = method(addr)
  File "unpyc3.py", line 1470, in POP_TOP
    self.stack.pop().on_pop(self)
AttributeError: 'Unpack' object has no attribute 'on_pop'
# Python 3.6 subprocess.py bug
# Bug is getting params correct: timeout before **kwargs
def call(*popenargs, timeout=None, **kwargs):
    return

# From 3.4 asyncio/base_events.py
# Bug was in pickin up name of ** (kwargs)
def subprocess_shell(self, protocol_factory, cmd, *, stdin=subprocess.PIPE,
                     stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                     universal_newlines=False, shell=True, bufsize=0,
                     **kwargs):
    return

# From 3.4 asyncio/locks.py
# Bug was handling" "value=1, *"

class BoundedSemaphore(Semaphore):
    def __init__(self, value=1, *, loop=None):
        super().__init__(value, loop=loop)
======= python-uncompyle6/test/bytecode_3.3/02_named_and_kwargs.pyc =========
Traceback (most recent call last):
  File "unpyc3.py", line 2021, in <module>
    print(decompile(sys.argv[1]))
  File "unpyc3.py", line 1195, in __str__
    self.display(istr)
  File "unpyc3.py", line 1201, in display
    stmt.display(indent)
  File "unpyc3.py", line 1044, in display
    self.display_undecorated(indent)
  File "unpyc3.py", line 1166, in display_undecorated
    suite = self.func.code.get_suite(look_for_docstring=True)
  File "unpyc3.py", line 302, in get_suite
    dec.run()
  File "unpyc3.py", line 1258, in run
    method = getattr(self, opname[opcode])
AttributeError: 'SuiteDecompiler' object has no attribute '<69>'
# From 3.3.5 turtledemo/bytedesign.py
# Python 3.2 and 3.3 adds this funny
# LOAD_FAST STORE_LOCALS
# which we translate to
# # inspect.currentframe().f_locals = __locals__
from turtle import Turtle
class Designer(Turtle):
    def design(self, homePos, scale):
        pass
======= python-uncompyle6/test/bytecode_3.3/05_store_locals.pyc =========
Traceback (most recent call last):
  File "unpyc3.py", line 2021, in <module>
    print(decompile(sys.argv[1]))
  File "unpyc3.py", line 1195, in __str__
    self.display(istr)
  File "unpyc3.py", line 1201, in display
    stmt.display(indent)
  File "unpyc3.py", line 1044, in display
    self.display_undecorated(indent)
  File "unpyc3.py", line 1166, in display_undecorated
    suite = self.func.code.get_suite(look_for_docstring=True)
  File "unpyc3.py", line 302, in get_suite
    dec.run()
  File "unpyc3.py", line 1258, in run
    method = getattr(self, opname[opcode])
AttributeError: 'SuiteDecompiler' object has no attribute '<69>'
#!/usr/bin/env python
# See https://github.com/rocky/python-uncompyle6/pull/15

# In Python 2.7, you should see
#   mkfuncdeco0 ::= mkfunc
#   classdefdeco2 ::= LOAD_CONST expr mkfunc CALL_FUNCTION_0 BUILD_CLASS
#   classdefdeco1 ::= expr classdefdeco1 CALL_FUNCTION_1
#   store        ::= STORE_NAME
#   classdefdeco ::= classdefdeco1 store

def author(*author_names):
    def author_func(cls):
        return cls
    return author_func

@author('Me', 'Him')
@author('You')
class MyClass(object):
    def __init__(self):
        pass

    @staticmethod
    @staticmethod
    def static_method():
        pass

x = MyClass()
======= python-uncompyle6/test/bytecode_3.3/10_classdec.pyc =========
Traceback (most recent call last):
  File "unpyc3.py", line 2021, in <module>
    print(decompile(sys.argv[1]))
  File "unpyc3.py", line 1195, in __str__
    self.display(istr)
  File "unpyc3.py", line 1201, in display
    stmt.display(indent)
  File "unpyc3.py", line 1044, in display
    self.display_undecorated(indent)
  File "unpyc3.py", line 1166, in display_undecorated
    suite = self.func.code.get_suite(look_for_docstring=True)
  File "unpyc3.py", line 302, in get_suite
    dec.run()
  File "unpyc3.py", line 1258, in run
    method = getattr(self, opname[opcode])
AttributeError: 'SuiteDecompiler' object has no attribute '<69>'
# Ensures opcodes DELETE_SUBSCR and DELETE_GLOBAL are covered
a = (1, 2, 3)
# DELETE_NAME
del a

# DELETE_SUBSCR
b = [4, 5, 6]
del b[1]
del b[:]

# del_stmt ::= expr expr DELETE_SLICE+1
l = [None] * 10
del l[-2:]

c = [0,1,2,3,4]
del c[:1]
del c[2:3]

d = [0,1,2,3,4,5,6]
del d[1:3:2]

e = ('a', 'b')
def foo():
    # covers DELETE_GLOBAL
    global e
    del e

z = {}

def a():
    b =1
    global z
    del z
    def b(y):
        global z
        # covers DELETE_FAST
        del y
        # LOAD_DEREF
        return z



======= python-uncompyle6/test/bytecode_3.3/10_del.pyc =========
Traceback (most recent call last):
  File "unpyc3.py", line 2021, in <module>
    print(decompile(sys.argv[1]))
  File "unpyc3.py", line 1195, in __str__
    self.display(istr)
  File "unpyc3.py", line 1201, in display
    stmt.display(indent)
  File "unpyc3.py", line 1044, in display
    self.display_undecorated(indent)
  File "unpyc3.py", line 1068, in display_undecorated
    self.code.get_suite().display(indent + 1)
  File "unpyc3.py", line 302, in get_suite
    dec.run()
  File "unpyc3.py", line 1262, in run
    new_addr = method(addr, arg)
  File "unpyc3.py", line 1538, in DELETE_GLOBAL
    self.declare_global(name)
AttributeError: 'SuiteDecompiler' object has no attribute 'declare_global'
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