From b28a375f2f4724c129e8683f548c8f1477e00a68 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 25 Jun 2013 00:17:37 +0200 Subject: 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. --- 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 index d8a5cd2..cde389a 100644 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -61,7 +61,6 @@ else: 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 @@ else: 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 @@ echo "import sys; print(sys.argv)" | idle - "foobar" 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 index 15f4472..74c1b89 100644 --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -40,7 +40,6 @@ else: 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 @@ def main(del_exitfunc=False): 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: -- cgit v0.12