File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-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 @@ -336,6 +336,18 @@ def test_does_not_crash_on_tuple_expansion_in_except_statement(self):
336
336
)
337
337
BugBearVisitor (filename = "<string>" , lines = []).visit (syntax_tree )
338
338
339
+ def test_does_not_crash_on_call_in_except_statement (self ):
340
+ # akin to test_does_not_crash_on_tuple_expansion_in_except_statement
341
+ # see https://github.com/PyCQA/flake8-bugbear/issues/171
342
+ syntax_tree = ast .parse (
343
+ "foo = lambda: IOError\n "
344
+ "try:\n "
345
+ " ...\n "
346
+ "except (foo(),):\n "
347
+ " ...\n "
348
+ )
349
+ BugBearVisitor (filename = "<string>" , lines = []).visit (syntax_tree )
350
+
339
351
340
352
if __name__ == "__main__" :
341
353
unittest .main ()
You can’t perform that action at this time.
0 commit comments