bpo-40334: Produce better error messages on invalid targets#20106
Conversation
The following error messages get produced: - `cannot delete ...` for invalid `del` targets - `... is an illegal 'for' target` for invalid targets in for statements - `... is an illegal 'with' target` for invalid targets in with statements Additionally a few `cut`s were added in various places before the invocation of the `invalid_*` rule, in order to speed things up.
|
Since the error messages will not change I removed the |
Sorry, something went wrong.
gvanrossum
left a comment
There was a problem hiding this comment.
Almost there!
Sorry, something went wrong.
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Correctly identify invalid targets, when there are multiple context managers in a with statement, avoid SEGFAULT in invalid for targets and improve paremeter naming in _PyPegen_get_invalid_target.
gvanrossum
left a comment
There was a problem hiding this comment.
Hm... I poked another hole here. :-(
>>> for i, (f, g()) in 10: pass
Assertion failed: (e != NULL && e->kind == Compare_kind), function _PyPegen_get_invalid_for_target, file Parser/pegen/pegen.c, line 2110.
Abort trap: 6
Sorry, something went wrong.
|
Simpler example that gets the same error: And this too: I recommend extreme caution here. If I can poke holes this quickly, I worry that we may be causing a regression if we rush this in before beta1. We obviously don't have the right testing strategy here. There's nothing that says we have to get this level of detail right in beta1. |
Sorry, something went wrong.
…PyPegen_get_invalid_target
I pushed a version that I think is pretty close, but I'm not 100% certain. I agree, that there's no rush to land this and that we should test a bit more. |
Sorry, something went wrong.
What I meant is that; since this PR already generates 'can't use starred expression here' error messages for some cases, it isn't fully compatible with the old parser.
|
Sorry, something went wrong.
I think I understand now. Indeed the old parser used to produce Also, I can remember @pablogsal mentioning somewhere that changing just the message is okay in terms of backwards-compatibility. |
Sorry, something went wrong.
I see, didn't notice that. Sorry for distraction.
So, is this error will be kept ( |
Sorry, something went wrong.
|
I like the |
Sorry, something went wrong.
|
Same here. |
Sorry, something went wrong.
pablogsal
left a comment
There was a problem hiding this comment.
After reviewing it again I have played with it a bit more (before the CHECK commit) and I was not able to break it in any way so I think we can land it now so more people interact with it and it this way we could detect any non-trivial problems if they exist.
Sorry, something went wrong.
a00b611 to
55b5327
Compare
June 18, 2020 22:41
|
FYI there is an unrelated CI failure on macOS in test_asyncio. |
Sorry, something went wrong.
|
Thanks @lysnikolaou for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
Sorry, something went wrong.
|
Sorry, @lysnikolaou and @pablogsal, I could not cleanly backport this to |
Sorry, something went wrong.
Of course, on it. |
Sorry, something went wrong.
…-20106) The following error messages get produced: - `cannot delete ...` for invalid `del` targets - `... is an illegal 'for' target` for invalid targets in for statements - `... is an illegal 'with' target` for invalid targets in with statements Additionally, a few `cut`s were added in various places before the invocation of the `invalid_*` rule, in order to speed things up. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> (cherry picked from commit 01ece63)
…-20106) (GH-20973) * bpo-40334: Produce better error messages on invalid targets (GH-20106) The following error messages get produced: - `cannot delete ...` for invalid `del` targets - `... is an illegal 'for' target` for invalid targets in for statements - `... is an illegal 'with' target` for invalid targets in with statements Additionally, a few `cut`s were added in various places before the invocation of the `invalid_*` rule, in order to speed things up. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> (cherry picked from commit 01ece63)
|
FYI, appears to have caused a regression: https://bugs.python.org/issue41060. |
Sorry, something went wrong.
…-20106) The following error messages get produced: - `cannot delete ...` for invalid `del` targets - `... is an illegal 'for' target` for invalid targets in for statements - `... is an illegal 'with' target` for invalid targets in with statements Additionally, a few `cut`s were added in various places before the invocation of the `invalid_*` rule, in order to speed things up. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
The following error messages get produced:
cannot delete ...for invaliddeltargetscannot assign to ...for invalid targets in for and withstatements
Additionally a few
cuts were added in various places before theinvocation of the
invalid_*rule, in order to speed thingsup.
https://bugs.python.org/issue40334