Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

except_clause no except_item #70

Open
gilosh opened this issue Jun 18, 2020 · 3 comments
Open

except_clause no except_item #70

gilosh opened this issue Jun 18, 2020 · 3 comments

Comments

@gilosh
Copy link

gilosh commented Jun 18, 2020

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
Copy link

Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.57. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@maxbrunsfeld
Copy link
Contributor

maxbrunsfeld commented Jun 18, 2020

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?

@gilosh
Copy link
Author

gilosh commented Jun 18, 2020

Right! I was under the wrong assumption you could have multiple exceptions (I should have double checked with the interpreter).

  1. 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:
  1. Your solution for adding the fields sounds perfect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants