Kaydet (Commit) b28a375f authored tarafından Victor Stinner's avatar Victor Stinner

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.
üst 7660b880
...@@ -61,7 +61,6 @@ else: ...@@ -61,7 +61,6 @@ else:
lineno, line=line)) lineno, line=line))
except OSError: except OSError:
pass ## file (probably __stderr__) is invalid, warning dropped. pass ## file (probably __stderr__) is invalid, warning dropped.
warnings.showwarning = idle_showwarning
def idle_formatwarning(message, category, filename, lineno, line=None): def idle_formatwarning(message, category, filename, lineno, line=None):
"""Format warnings the IDLE way""" """Format warnings the IDLE way"""
s = "\nWarning (from warnings module):\n" s = "\nWarning (from warnings module):\n"
...@@ -73,7 +72,6 @@ else: ...@@ -73,7 +72,6 @@ else:
s += " %s\n" % line s += " %s\n" % line
s += "%s: %s\n>>> " % (category.__name__, message) s += "%s: %s\n>>> " % (category.__name__, message)
return s return s
warnings.formatwarning = idle_formatwarning
def extended_linecache_checkcache(filename=None, def extended_linecache_checkcache(filename=None,
orig_checkcache=linecache.checkcache): orig_checkcache=linecache.checkcache):
...@@ -1425,6 +1423,9 @@ echo "import sys; print(sys.argv)" | idle - "foobar" ...@@ -1425,6 +1423,9 @@ echo "import sys; print(sys.argv)" | idle - "foobar"
def main(): def main():
global flist, root, use_subprocess global flist, root, use_subprocess
warnings.showwarning = idle_showwarning
warnings.formatwarning = idle_formatwarning
use_subprocess = True use_subprocess = True
enable_shell = False enable_shell = False
enable_edit = False enable_edit = False
......
...@@ -40,7 +40,6 @@ else: ...@@ -40,7 +40,6 @@ else:
s += " %s\n" % line s += " %s\n" % line
s += "%s: %s\n" % (category.__name__, message) s += "%s: %s\n" % (category.__name__, message)
return s return s
warnings.formatwarning = idle_formatwarning_subproc
tcl = tkinter.Tcl() tcl = tkinter.Tcl()
...@@ -82,6 +81,9 @@ def main(del_exitfunc=False): ...@@ -82,6 +81,9 @@ def main(del_exitfunc=False):
global exit_now global exit_now
global quitting global quitting
global no_exitfunc global no_exitfunc
warnings.formatwarning = idle_formatwarning_subproc
no_exitfunc = del_exitfunc no_exitfunc = del_exitfunc
#time.sleep(15) # test subprocess not responding #time.sleep(15) # test subprocess not responding
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment