-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
codeop: 3.8.5 regression, warnings.simplefilter('error', SyntaxWarning) does not raise. #85692
Comments
assuming $ cat foo.py
import warnings
from codeop import compile_command warnings.simplefilter('error', SyntaxWarning)
res = compile_command('1 is 1\n', symbol='exec')
print('Res', res) On 3.8.0...3.8.4 this correctly raises a SyntaxError: python foo.py
Traceback (most recent call last):
File "foo.py", line 5, in <module>
res = compile_command('1 is 1\n', symbol='exec')
File "/Users/bussonniermatthias/miniconda3/envs/38/lib/python3.8/codeop.py", line 122, in compile_command
return _maybe_compile(_compile, source, filename, symbol)
File "/Users/bussonniermatthias/miniconda3/envs/38/lib/python3.8/codeop.py", line 99, in _maybe_compile
raise err1
File "/Users/bussonniermatthias/miniconda3/envs/38/lib/python3.8/codeop.py", line 87, in _maybe_compile
code1 = compiler(source + "\n", filename, symbol)
File "/Users/bussonniermatthias/miniconda3/envs/38/lib/python3.8/codeop.py", line 102, in _compile
return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT)
File "<input>", line 1
SyntaxError: "is" with a literal. Did you mean "=="? But will silently return None on 3.8.5 $ python foo.py
Res None |
seem to affect 3.8.4 as well. |
Potentially due to |
I proposed a fix: PR 21838. Would you mind to review it? |
Thanks Matthias Bussonnier for the fix. The regression should now be fixed. Also, I converted your reproducer into a regression test. |
Thank *YOU* for the fix, and the bug report is initially from tcaswell. At least on 3.8 branch this is fixed for me. Just for completeness, this was discovered as in IPython we try to guess whether "enter" is "insert new line" or "execute", and Much love for the fast turnaround; looking fwd to 3.9 |
Thanks tcaswell in this case ;-) |
This 'fix' introduces another regression by undoing the previous fix in bpo-40807 of emitting DeprecationWarning (for '\e', for instance) just once instead of thrice. I suspect that the example of Matthias would fail in a debug build (with DeprecationWarnings on) for DeprecationWarning also. PR-21848 removes the limitation of the first fix to SyntaxWarning and includes DeprecationWarning in the test for single emission. |
The commit 369a1cb introduces a change in environment. I haven't checked the other PR though to see if this is fixed. ./python.exe -m test --fail-env-changed test_codeop -m test_warning == Tests result: ENV CHANGED == 1 test altered the execution environment: Total duration: 38 ms On an unrelated note the test passes with verbose mode though fail-env-changed flag is passed. ./python.exe -m test --fail-env-changed test_codeop -m test_warning -vvv ---------------------------------------------------------------------- Ran 1 test in 0.001s OK == Tests result: SUCCESS == 1 test OK. Total duration: 58 ms |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: