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):
125
125
# "pkg.mod.error", handling any depth of attribute accesses.
126
126
if isinstance (node , ast .Name ):
127
127
return node .id
128
+ if isinstance (node , ast .Call ):
129
+ return _to_name_str (node .func )
128
130
try :
129
131
return _to_name_str (node .value ) + "." + node .attr
130
132
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):
339
339
)
340
340
BugBearVisitor (filename = "<string>" , lines = []).visit (syntax_tree )
341
341
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
+
342
350
343
351
if __name__ == "__main__" :
344
352
unittest .main ()
You can’t perform that action at this time.
0 commit comments