tree-sitter-python
tree-sitter-python copied to clipboard
except_clause no except_item
For the following code:
try:
pass
except Exception as e:
pass
... except_clause )
identifier )
identifier )
block ) ...
It would be helpful to have an 'except_item' similarly to 'with_item', helping distinguish between the identifiers:
with_item )
value: identifier )
alias: identifier )
.. # suggestion
except_item )
value: identifier )
alias: identifier )
Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.57. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!
Links: app homepage, dashboard and code for this bot.
I think except_item isn't needed as clearly as with_item, because unlike with_item, there can only be one item in each except_clause.
I'm still open to this change though. Alternatively, should we just put a value and alias fields in except_clause?
Right! I was under the wrong assumption you could have multiple exceptions (I should have double checked with the interpreter).
- Would you say that this is a bug then?
try:
pass
except RuntimeError, TypeError:
pass
try_statement [0, 0] - [3, 6])
...
except_clause [2, 0] - [3, 6])
identifier [2, 7] - [2, 19])
identifier [2, 21] - [2, 30])
block [3, 2] - [3, 6])
...
CPython
File "<stdin>", line 3
except RuntimeError, TypeError:
- Your solution for adding the fields sounds perfect