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

Skip to content

TypeError: object of type 'Token' has no len() #377

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
dkw72n opened this issue Dec 31, 2021 · 0 comments · Fixed by #379
Closed

TypeError: object of type 'Token' has no len() #377

dkw72n opened this issue Dec 31, 2021 · 0 comments · Fixed by #379

Comments

@dkw72n
Copy link

dkw72n commented Dec 31, 2021

Description

The following exception raised on certain input:

Traceback (most recent call last):
  File "test_pythonlib.py", line 311, in <module>
    do_tests(src_dir, pattern, target_dir, test_opts)
  File "test_pythonlib.py", line 212, in do_tests
    src_dir, target_dir, files, [], do_verify=opts["do_verify"]
  File "/tmp/python-uncompyle6/uncompyle6/main.py", line 312, in main
    do_fragments,
  File "/tmp/python-uncompyle6/uncompyle6/main.py", line 215, in decompile_file
    do_fragments=do_fragments,
  File "/tmp/python-uncompyle6/uncompyle6/main.py", line 134, in decompile 
    co, out, bytecode_version, debug_opts=debug_opts, is_pypy=is_pypy
  File "/tmp/python-uncompyle6/uncompyle6/semantics/pysource.py", line 2604, in code_deparse
    deparsed.ast = deparsed.build_ast(tokens, customize, co, isTopLevel=isTopLevel)
  File "/tmp/python-uncompyle6/uncompyle6/semantics/pysource.py", line 2544, in build_ast 
    transform_ast = self.treeTransform.transform(ast, code)
  File "/tmp/python-uncompyle6/uncompyle6/semantics/transform.py", line 449, in transform 
    self.ast = self.traverse(self.ast, is_lambda=False)
  File "/tmp/python-uncompyle6/uncompyle6/semantics/transform.py", line 443, in traverse
    node = self.preorder(node)
  File "/tmp/python-uncompyle6/uncompyle6/semantics/transform.py", line 103, in preorder
    node[i] = self.preorder(kid)
  File "/tmp/python-uncompyle6/uncompyle6/semantics/transform.py", line 103, in preorder
    node[i] = self.preorder(kid)
  File "/tmp/python-uncompyle6/uncompyle6/semantics/transform.py", line 103, in preorder
    node[i] = self.preorder(kid)
  [Previous line repeated 3 more times]
  File "/tmp/python-uncompyle6/uncompyle6/semantics/transform.py", line 98, in preorder
    node = func(node)
  File "/tmp/python-uncompyle6/uncompyle6/semantics/transform.py", line 296, in n_ifelsestmt
    if len_n == 1 == len(n[0]) and n[0] == "stmt":
TypeError: object of type 'Token' has no len()

How to Reproduce

compile the following code with python2.7 as an input:

for name in slots:
    if y:
        pass
    else:
        continue
        if x:
            y()
        else:
            z()

Expected behavior

no exception raised

dkw72n pushed a commit to dkw72n/python-uncompyle6 that referenced this issue Dec 31, 2021
rocky added a commit that referenced this issue Dec 31, 2021
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

Successfully merging a pull request may close this issue.

1 participant