[issue34857] IDLE: SyntaxWarning not handled properly
Serhiy Storchaka
report at bugs.python.org
Sun Aug 11 12:21:42 EDT 2019
Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:
I cannot reproduce this behavior in 3.7+. `assert (0, 'bad')` does not have any effect. But in 3.6 it outputs a traceback to the stderr.
$ ./python -m idlelib
Exception in Tkinter callback
Traceback (most recent call last):
File "/home/serhiy/py/cpython3.6/Lib/tkinter/__init__.py", line 1705, in __call__
return self.func(*args)
File "/home/serhiy/py/cpython3.6/Lib/idlelib/multicall.py", line 176, in handler
r = l[i](event)
File "/home/serhiy/py/cpython3.6/Lib/idlelib/pyshell.py", line 1205, in enter_callback
self.runit()
File "/home/serhiy/py/cpython3.6/Lib/idlelib/pyshell.py", line 1246, in runit
self.interp.runsource(line)
File "/home/serhiy/py/cpython3.6/Lib/idlelib/pyshell.py", line 684, in runsource
return InteractiveInterpreter.runsource(self, source, filename)
File "/home/serhiy/py/cpython3.6/Lib/code.py", line 64, in runsource
code = self.compile(source, filename, symbol)
File "/home/serhiy/py/cpython3.6/Lib/codeop.py", line 168, in __call__
return _maybe_compile(self.compiler, source, filename, symbol)
File "/home/serhiy/py/cpython3.6/Lib/codeop.py", line 82, in _maybe_compile
code = compiler(source, filename, symbol)
File "/home/serhiy/py/cpython3.6/Lib/codeop.py", line 133, in __call__
codeob = compile(source, filename, symbol, self.flags, 1)
SyntaxWarning: assertion is always true, perhaps remove parentheses?
But other syntax warnings are converted to errors in IDLE (reported by Raymond in https://bugs.python.org/issue15248#msg349375).
In the regular interactive interpreter:
>>> 0 is 0
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True
>>> data = [
... (1, 2, 3) # oops, missing comma!
... (4, 5, 6)
... ]
<stdin>:2: SyntaxWarning: 'tuple' object is not callable; perhaps you missed a comma?
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
TypeError: 'tuple' object is not callable
In IDLE:
>>> 0 is 0
SyntaxError: "is" with a literal. Did you mean "=="?
>>> data = [
(1, 2, 3) # oops, missing comma!
(4, 5, 6)
]
SyntaxError: 'tuple' object is not callable; perhaps you missed a comma?
----------
nosy: +serhiy.storchaka
versions: +Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34857>
_______________________________________
More information about the Python-bugs-list
mailing list