summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-03-26 17:41:35 (GMT)
committerGuido van Rossum <guido@python.org>2001-03-26 17:41:35 (GMT)
commitb4ce43011e5d3ad43a421f1e2d366f0ce8cd36dc (patch)
treee8bf8d8434a412d795631f36a6fe95450f8889e3
parent55a0034682e8128ad9629e8da8de78f1e02a21cd (diff)
downloadcpython-b4ce43011e5d3ad43a421f1e2d366f0ce8cd36dc.zip
cpython-b4ce43011e5d3ad43a421f1e2d366f0ce8cd36dc.tar.gz
cpython-b4ce43011e5d3ad43a421f1e2d366f0ce8cd36dc.tar.bz2
Turn SyntasWarning into SyntaxError for all code entered
interactively.
-rw-r--r--Tools/idle/PyShell.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Tools/idle/PyShell.py b/Tools/idle/PyShell.py
index 86c0f6b..bae4e16 100644
--- a/Tools/idle/PyShell.py
+++ b/Tools/idle/PyShell.py
@@ -5,6 +5,7 @@ import sys
import string
import getopt
import re
+import warnings
import linecache
from code import InteractiveInterpreter
@@ -180,7 +181,14 @@ class ModifiedInterpreter(InteractiveInterpreter):
# Extend base class to stuff the source in the line cache first
filename = self.stuffsource(source)
self.more = 0
- return InteractiveInterpreter.runsource(self, source, filename)
+ self.save_warnings_filters = warnings.filters[:]
+ warnings.filterwarnings(action="error", category=SyntaxWarning)
+ try:
+ return InteractiveInterpreter.runsource(self, source, filename)
+ finally:
+ if self.save_warnings_filters is not None:
+ warnings.filters[:] = self.save_warnings_filters
+ self.save_warnings_filters = None
def stuffsource(self, source):
# Stuff source in the filename cache
@@ -249,6 +257,9 @@ class ModifiedInterpreter(InteractiveInterpreter):
def runcode(self, code):
# Override base class method
+ if self.save_warnings_filters is not None:
+ warnings.filters[:] = self.save_warnings_filters
+ self.save_warnings_filters = None
debugger = self.debugger
try:
self.tkconsole.beginexecuting()