-
Notifications
You must be signed in to change notification settings - Fork 142
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
Don't do eval/exec inside of except
clause
#812
Comments
The reason why this happens is that we try to evaluate the code as an expression first (so that we can print out the result if there is one), and only if that fails, try treating it as a statement. Basically something like: try:
code = compile(src, "<string>", "eval")
except Exception:
code = compile(src, "<string>", "exec") Since The same issue appears if you try to run e.g. To avoid this, we shouldn't be doing |
Thanks for the explanation! |
except
clause
I too came across a similar issue and wondered why the debug console is complaining about a syntax error.
|
Environment data
Actual behavior
In the debug console of VS Code there is a syntax error when using an f string in an assert statement. The same line does not produce a syntax error without a debuger or in VS Code when using run and debug.
Expected behavior
For the example script below there should be no syntax error when trying to run a line similar to below in the debug console.
Steps to reproduce:
Example Script:
The text was updated successfully, but these errors were encountered: