-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Don't crash on unexpected PY2 except syntax #4011
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
Conversation
mypy/fastparse2.py
Outdated
raise RuntimeError("'{}' has non-Name name.".format(ast27.dump(item))) | ||
|
||
vs = [produce_name(h) for h in handlers] | ||
self.fail("Sorry, `except <expr>, (<tuple>)` is not supported", item.lineno, item.col_offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be something other than a tuple however. For example, this works fine at runtime:
try:
raise Exception('foo', 'bar')
except Exception, [a, b]:
print a, b # prints foo bar
Perhaps just "Unsupported exception handler syntax ..."
. If you want a specific warning, you can check that the item.name
is an ast27.Tuple
or ast27.List
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change it to except <expr>, <anything but a name>
-- it's syntactically an assignment target. I still don't think it's worth trying to support other syntax -- we just need to not crash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
Whoa, needs tests first. |
Sorry, yes it needs tests. I meant the changes look good (beyond needing tests). |
Travis flaked on 3.7, so I restarted it. |
Fixes #3772
Still needs a test.