Skip to content

Commit c599e9f

Browse files
terryjreedylisroach
authored andcommitted
bpo-37824: Properly handle user input warnings in IDLE shell. (pythonGH-15500)
Cease turning SyntaxWarnings into SyntaxErrors.
1 parent 4870c52 commit c599e9f

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

Lib/idlelib/NEWS.txt

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ Released on 2019-10-20?
33
======================================
44

55

6+
bpo-37824: Properly handle user input warnings in IDLE shell.
7+
Cease turning SyntaxWarnings into SyntaxErrors.
8+
9+
bpo-37929: IDLE Settings dialog now closes properly when there is no
10+
shell window.
11+
612
bpo-37849: Fix completions list appearing too high or low when shown
713
above the current line.
814

Lib/idlelib/pyshell.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ def __init__(self, tkconsole):
394394
self.tkconsole = tkconsole
395395
locals = sys.modules['__main__'].__dict__
396396
InteractiveInterpreter.__init__(self, locals=locals)
397-
self.save_warnings_filters = None
398397
self.restarting = False
399398
self.subprocess_arglist = None
400399
self.port = PORT
@@ -665,8 +664,6 @@ def runsource(self, source):
665664
"Extend base class method: Stuff the source in the line cache first"
666665
filename = self.stuffsource(source)
667666
self.more = 0
668-
self.save_warnings_filters = warnings.filters[:]
669-
warnings.filterwarnings(action="error", category=SyntaxWarning)
670667
# at the moment, InteractiveInterpreter expects str
671668
assert isinstance(source, str)
672669
#if isinstance(source, str):
@@ -677,14 +674,9 @@ def runsource(self, source):
677674
# self.tkconsole.resetoutput()
678675
# self.write("Unsupported characters in input\n")
679676
# return
680-
try:
681-
# InteractiveInterpreter.runsource() calls its runcode() method,
682-
# which is overridden (see below)
683-
return InteractiveInterpreter.runsource(self, source, filename)
684-
finally:
685-
if self.save_warnings_filters is not None:
686-
warnings.filters[:] = self.save_warnings_filters
687-
self.save_warnings_filters = None
677+
# InteractiveInterpreter.runsource() calls its runcode() method,
678+
# which is overridden (see below)
679+
return InteractiveInterpreter.runsource(self, source, filename)
688680

689681
def stuffsource(self, source):
690682
"Stuff source in the filename cache"
@@ -763,9 +755,6 @@ def runcode(self, code):
763755
if self.tkconsole.executing:
764756
self.interp.restart_subprocess()
765757
self.checklinecache()
766-
if self.save_warnings_filters is not None:
767-
warnings.filters[:] = self.save_warnings_filters
768-
self.save_warnings_filters = None
769758
debugger = self.debugger
770759
try:
771760
self.tkconsole.beginexecuting()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Properly handle user input warnings in IDLE shell. Cease turning
2+
SyntaxWarnings into SyntaxErrors.

0 commit comments

Comments
 (0)