Open BarrensZeppelin opened 2 years ago
I imagine the fix would be to return an empty list in _name_nodes if the node does not match one of the two supported scenarios.
Yes, this does sound like a reasonable approach. We probably don't want to get into the business of trying to examine arbitrary expressions to find exception names to change.
The implementation of
ExceptionReplacer._name_nodes
expects exception clauses to either contain a singleName
ast node or be a tuple of such nodes. However, the Python specification allows arbitrary expressions for exception clauses. This means that you can make the function crash if it is given an unexpected exception clause, such as:(which is nonsense and only catches
IndexError
, but is valid Python nonetheless)This is the traceback when running
cosmic-ray init ...
:And the relevant part of
ExceptionReplacer
:I imagine the fix would be to return an empty list in
_name_nodes
if the node does not match one of the two supported scenarios.