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

Python: Implicit decorator calls breaks process_assign with AssertionError #36

Closed
sudodoki opened this issue Dec 11, 2021 · 5 comments
Closed

Comments

@sudodoki
Copy link

Sample code

from typing import Callable

def trace(fn: Callable) -> Callable:
    def wrapper(*args, **kwargs):
        print('traced call')
        return fn(*args, **kwargs)
    return wrapper

def do_something(msg):
    return msg + ' world'

message = 'hello'
new_message = trace(do_something)(message)

when fed into code2flow would produce an AssertionError

File "%/bin/code2flow", line 33, in <module>
sys.exit(load_entry_point('code2flow', 'console_scripts', 'code2flow')())
File "%/code2flow/engine.py", line 630, in main
code2flow(
File "%/code2flow/engine.py", line 536, in code2flow
file_groups, all_nodes, edges = map_it(sources, language, no_trimming,
File "%/code2flow/engine.py", line 324, in map_it
file_group = make_file_group(file_ast_tree, source, extension)
File "%/code2flow/engine.py", line 208, in make_file_group
file_group.add_node(language.make_root_node(body_trees, parent=file_group), is_root=True)
File "%/code2flow/python.py", line 229, in make_root_node
variables = make_local_variables(lines, parent)
File "%/code2flow/python.py", line 120, in make_local_variables
variables += process_assign(element)
File "%/code2flow/python.py", line 79, in process_assign
ret.append(Variable(token, call, element.lineno))
File "%/code2flow/model.py", line 159, in __init__
assert points_to
@scottrogowski
Copy link
Owner

Just acknowledging that I've seen this and tested myself. It appears to be a real bug.

@scottrogowski
Copy link
Owner

Easy fix. Let me know if you think this is incorrect for some reason #39

@scottrogowski
Copy link
Owner

And thank you for the bug report!

@aurelg
Copy link

aurelg commented Dec 12, 2021

#39 fixes it for me, at least.

@scottrogowski
Copy link
Owner

Implemented in 2.3.1. Feel free to reopen if there are problems

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

3 participants