File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,8 @@ def _to_name_str(node):
125125 # "pkg.mod.error", handling any depth of attribute accesses.
126126 if isinstance (node , ast .Name ):
127127 return node .id
128+ if isinstance (node , ast .Call ):
129+ return _to_name_str (node .func )
128130 try :
129131 return _to_name_str (node .value ) + "." + node .attr
130132 except AttributeError :
Original file line number Diff line number Diff line change @@ -339,6 +339,14 @@ def test_does_not_crash_on_tuple_expansion_in_except_statement(self):
339339 )
340340 BugBearVisitor (filename = "<string>" , lines = []).visit (syntax_tree )
341341
342+ def test_does_not_crash_on_call_in_except_statement (self ):
343+ # akin to test_does_not_crash_on_tuple_expansion_in_except_statement
344+ # see https://github.com/PyCQA/flake8-bugbear/issues/171
345+ syntax_tree = ast .parse (
346+ "foo = lambda: IOError\n try:\n ...\n except (foo(),):\n ...\n "
347+ )
348+ BugBearVisitor (filename = "<string>" , lines = []).visit (syntax_tree )
349+
342350
343351if __name__ == "__main__" :
344352 unittest .main ()
You can’t perform that action at this time.
0 commit comments