-
-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Python/compile.c:7482: int compute_code_flags(struct compiler *): Assertion `IS_TOP_LEVEL_AWAIT(c) || _PyST_IsFunctionLike(ste)' failed #121637
Comments
cc: @iritkatriel -- it looks like you've got a few commits in this file in that range, though I don't see one that's obviously relevant. |
Feels related to #121297. |
I will add both |
Irit is on vacation, I'll look into this over the next few days. |
The problem is arguably this:
It used to be that we didn't raise a SyntaxError if there is an Now, however, the symtable sets I can see two solutions:
The latter seems like the more intuitive behavior for users. It's also consistent with other cases where optimized-away code leads to a compile error:
So I'll send a PR to make |
Always doing a syntax error, even if the assert is optimized out, feels like the right behavior to me. |
I realized there's a few more similar cases (essentially, every place we call
The latter also crashes on current main:
|
The linked PR makes symtable.c detect incorrect await and async comprehensions, fixing this issue. I didn't bother detecting other compiler errors (e.g., invalid yields) because they don't cause similar crashes. I wouldn't be surprised though if there's a crash lurking somewhere with e.g. |
Of course! It must have been an oversight that we didn't do this from the start. I'm removing the |
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Thanks for the report! This will now be a SyntaxError. |
Crash report
What happened?
Full stacktrace:
This regressed somewhere in f621618...690b935
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: