(original) (raw)

This fix is still not correct as warnings.formatwarning should not be overridden, only showwarning can be.

On Jun 24, 2013 6:18 PM, "victor.stinner" <python-checkins@python.org> wrote:
http://hg.python.org/cpython/rev/2a9e1eb3719c
changeset: 84330:2a9e1eb3719c
user: Victor Stinner <victor.stinner@gmail.com>
date: Tue Jun 25 00:17:37 2013 +0200
summary:
Issue #18081: Workaround "./python -m test\_idle test\_logging" failure

"import idlelib" should not install hooks on the warning modules, hooks should
only be installed when IDLE is started.

files:
Lib/idlelib/PyShell.py | 5 +++--
Lib/idlelib/run.py | 4 +++-
2 files changed, 6 insertions(+), 3 deletions(-)


diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
\--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -61,7 +61,6 @@
lineno, line=line))
except OSError:
pass ## file (probably \_\_stderr\_\_) is invalid, warning dropped.
\- warnings.showwarning = idle\_showwarning
def idle\_formatwarning(message, category, filename, lineno, line=None):
"""Format warnings the IDLE way"""
s = "\\nWarning (from warnings module):\\n"
@@ -73,7 +72,6 @@
s += " %s\\n" % line
s += "%s: %s\\n>>> " % (category.\_\_name\_\_, message)
return s
\- warnings.formatwarning = idle\_formatwarning

def extended\_linecache\_checkcache(filename=None,
orig\_checkcache=linecache.checkcache):
@@ -1425,6 +1423,9 @@
def main():
global flist, root, use\_subprocess

\+ warnings.showwarning = idle\_showwarning
\+ warnings.formatwarning = idle\_formatwarning
+
use\_subprocess = True
enable\_shell = False
enable\_edit = False
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
\--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -40,7 +40,6 @@
s += " %s\\n" % line
s += "%s: %s\\n" % (category.\_\_name\_\_, message)
return s
\- warnings.formatwarning = idle\_formatwarning\_subproc


tcl = tkinter.Tcl()
@@ -82,6 +81,9 @@
global exit\_now
global quitting
global no\_exitfunc
+
\+ warnings.formatwarning = idle\_formatwarning\_subproc
+
no\_exitfunc = del\_exitfunc
#time.sleep(15) # test subprocess not responding
try:

\--
Repository URL: http://hg.python.org/cpython

\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Python-checkins mailing list
Python-checkins@python.org
http://mail.python.org/mailman/listinfo/python-checkins