Run flake8-bugbear on this file:
try: x
except (a, (b, c)): pass
And you will get a stack trace that ends with
File "/Users/jelle/py/venvs/py311/lib/python3.11/site-packages/bugbear.py", line 283, in visit_ExceptHandler
names = [_to_name_str(e) for e in node.type.elts]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jelle/py/venvs/py311/lib/python3.11/site-packages/bugbear.py", line 283, in <listcomp>
names = [_to_name_str(e) for e in node.type.elts]
^^^^^^^^^^^^^^^
File "/Users/jelle/py/venvs/py311/lib/python3.11/site-packages/bugbear.py", line 202, in _to_name_str
return _to_name_str(node.value)
^^^^^^^^^^
AttributeError: 'Tuple' object has no attribute 'value'
Why would you use nested tuples in except handlers, you may ask. I'm not sure, but it's legal syntax so I am testing it in the pyanalyze test suite.
Run flake8-bugbear on this file:
And you will get a stack trace that ends with
Why would you use nested tuples in except handlers, you may ask. I'm not sure, but it's legal syntax so I am testing it in the pyanalyze test suite.