From 077887059a5b3d38161dfd74b160c701445a1ef0 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Sun, 25 Aug 2019 23:52:45 -0700 Subject: [PATCH] bpo-37824: Properly handle user input warnings in IDLE shell. (GH-15500) Cease turning SyntaxWarnings into SyntaxErrors. (cherry picked from commit 1039f39c9c6edb4c185856c19316d3a4eb561c38) Co-authored-by: Terry Jan Reedy --- Lib/idlelib/NEWS.txt | 6 ++++++ Lib/idlelib/pyshell.py | 17 +++-------------- .../2019-08-26-00-41-53.bpo-37824.YY5jAI.rst | 2 ++ 3 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 Misc/NEWS.d/next/IDLE/2019-08-26-00-41-53.bpo-37824.YY5jAI.rst diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index 45918cf36b4..949b30bd99c 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -3,6 +3,12 @@ Released on 2019-10-20? ====================================== +bpo-37824: Properly handle user input warnings in IDLE shell. +Cease turning SyntaxWarnings into SyntaxErrors. + +bpo-37929: IDLE Settings dialog now closes properly when there is no +shell window. + bpo-37849: Fix completions list appearing too high or low when shown above the current line. diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py index 87401f33f55..ea9465568bd 100755 --- a/Lib/idlelib/pyshell.py +++ b/Lib/idlelib/pyshell.py @@ -394,7 +394,6 @@ class ModifiedInterpreter(InteractiveInterpreter): self.tkconsole = tkconsole locals = sys.modules['__main__'].__dict__ InteractiveInterpreter.__init__(self, locals=locals) - self.save_warnings_filters = None self.restarting = False self.subprocess_arglist = None self.port = PORT @@ -665,8 +664,6 @@ class ModifiedInterpreter(InteractiveInterpreter): "Extend base class method: Stuff the source in the line cache first" filename = self.stuffsource(source) self.more = 0 - self.save_warnings_filters = warnings.filters[:] - warnings.filterwarnings(action="error", category=SyntaxWarning) # at the moment, InteractiveInterpreter expects str assert isinstance(source, str) #if isinstance(source, str): @@ -677,14 +674,9 @@ class ModifiedInterpreter(InteractiveInterpreter): # self.tkconsole.resetoutput() # self.write("Unsupported characters in input\n") # return - try: - # InteractiveInterpreter.runsource() calls its runcode() method, - # which is overridden (see below) - 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 + # InteractiveInterpreter.runsource() calls its runcode() method, + # which is overridden (see below) + return InteractiveInterpreter.runsource(self, source, filename) def stuffsource(self, source): "Stuff source in the filename cache" @@ -763,9 +755,6 @@ class ModifiedInterpreter(InteractiveInterpreter): if self.tkconsole.executing: self.interp.restart_subprocess() self.checklinecache() - 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() diff --git a/Misc/NEWS.d/next/IDLE/2019-08-26-00-41-53.bpo-37824.YY5jAI.rst b/Misc/NEWS.d/next/IDLE/2019-08-26-00-41-53.bpo-37824.YY5jAI.rst new file mode 100644 index 00000000000..1a1e8a59816 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2019-08-26-00-41-53.bpo-37824.YY5jAI.rst @@ -0,0 +1,2 @@ +Properly handle user input warnings in IDLE shell. Cease turning +SyntaxWarnings into SyntaxErrors.