-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
Description
When running code like so:
>>> from staticfg import CFGBuilder
>>> cfg = CFGBuilder().build_from_file('blah.py', './blah.py')
The CFGBuilder crashes if func_name is None.
File "/opt/homebrew/lib/python3.12/site-packages/staticfg/builder.py", line 275, in visit_Call
func_name = visit_func(func)
^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/staticfg/builder.py", line 267, in visit_func
func_name += "." + node.attr
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'
The relevant code:
def visit_Call(self, node):
def visit_func(node):
if type(node) == ast.Name:
return node.id
elif type(node) == ast.Attribute:
# Recursion on series of calls to attributes.
func_name = visit_func(node.value)
func_name += "." + node.attr
return func_nameI can work around this like so:
elif type(node) == ast.Attribute:
# Recursion on series of calls to attributes.
func_name = visit_func(node.value)
if func_name is None:
func_name = ""
func_name += "." + node.attr
return func_namebut that might just be masking the problem.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels