<p dir="ltr">This fix is still not correct as warnings.formatwarning should not be overridden, only showwarning can be.</p>
<div class="gmail_quote">On Jun 24, 2013 6:18 PM, "victor.stinner" <<a href="mailto:python-checkins@python.org">python-checkins@python.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<a href="http://hg.python.org/cpython/rev/2a9e1eb3719c" target="_blank">http://hg.python.org/cpython/rev/2a9e1eb3719c</a><br>
changeset:   84330:2a9e1eb3719c<br>
user:        Victor Stinner <<a href="mailto:victor.stinner@gmail.com">victor.stinner@gmail.com</a>><br>
date:        Tue Jun 25 00:17:37 2013 +0200<br>
summary:<br>
  Issue #18081: Workaround "./python -m test_idle test_logging" failure<br>
<br>
"import idlelib" should not install hooks on the warning modules, hooks should<br>
only be installed when IDLE is started.<br>
<br>
files:<br>
  Lib/idlelib/PyShell.py |  5 +++--<br>
  Lib/idlelib/run.py     |  4 +++-<br>
  2 files changed, 6 insertions(+), 3 deletions(-)<br>
<br>
<br>
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py<br>
--- a/Lib/idlelib/PyShell.py<br>
+++ b/Lib/idlelib/PyShell.py<br>
@@ -61,7 +61,6 @@<br>
                                               lineno, line=line))<br>
         except OSError:<br>
             pass  ## file (probably __stderr__) is invalid, warning dropped.<br>
-    warnings.showwarning = idle_showwarning<br>
     def idle_formatwarning(message, category, filename, lineno, line=None):<br>
         """Format warnings the IDLE way"""<br>
         s = "\nWarning (from warnings module):\n"<br>
@@ -73,7 +72,6 @@<br>
             s += "    %s\n" % line<br>
         s += "%s: %s\n>>> " % (category.__name__, message)<br>
         return s<br>
-    warnings.formatwarning = idle_formatwarning<br>
<br>
 def extended_linecache_checkcache(filename=None,<br>
                                   orig_checkcache=linecache.checkcache):<br>
@@ -1425,6 +1423,9 @@<br>
 def main():<br>
     global flist, root, use_subprocess<br>
<br>
+    warnings.showwarning = idle_showwarning<br>
+    warnings.formatwarning = idle_formatwarning<br>
+<br>
     use_subprocess = True<br>
     enable_shell = False<br>
     enable_edit = False<br>
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py<br>
--- a/Lib/idlelib/run.py<br>
+++ b/Lib/idlelib/run.py<br>
@@ -40,7 +40,6 @@<br>
             s += "    %s\n" % line<br>
         s += "%s: %s\n" % (category.__name__, message)<br>
         return s<br>
-    warnings.formatwarning = idle_formatwarning_subproc<br>
<br>
<br>
 tcl = tkinter.Tcl()<br>
@@ -82,6 +81,9 @@<br>
     global exit_now<br>
     global quitting<br>
     global no_exitfunc<br>
+<br>
+    warnings.formatwarning = idle_formatwarning_subproc<br>
+<br>
     no_exitfunc = del_exitfunc<br>
     #time.sleep(15) # test subprocess not responding<br>
     try:<br>
<br>
--<br>
Repository URL: <a href="http://hg.python.org/cpython" target="_blank">http://hg.python.org/cpython</a><br>
<br>_______________________________________________<br>
Python-checkins mailing list<br>
<a href="mailto:Python-checkins@python.org">Python-checkins@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-checkins" target="_blank">http://mail.python.org/mailman/listinfo/python-checkins</a><br>
<br></blockquote></div>