Kaydet (Commit) b4ce4301 authored tarafından Guido van Rossum's avatar Guido van Rossum

Turn SyntasWarning into SyntaxError for all code entered

interactively.
üst 55a00346
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment