From 352ebae87efdd8dead814dfc7b153dabb26317d8 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 16 Oct 2008 19:46:25 +0000 Subject: [PATCH] Merged revisions 66922 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r66922 | benjamin.peterson | 2008-10-16 14:40:14 -0500 (Thu, 16 Oct 2008) | 1 line use new showwarnings signature for idle #3391 ........ --- Lib/idlelib/PyShell.py | 12 ++++++++---- Lib/idlelib/run.py | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index a17f81ff402..c1b98a059f4 100644 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -55,18 +55,22 @@ try: except ImportError: pass else: - def idle_showwarning(message, category, filename, lineno): + def idle_showwarning(message, category, filename, lineno, + file=None, line=None): file = warning_stream try: - file.write(warnings.formatwarning(message, category, filename, lineno)) + file.write(warnings.formatwarning(message, category, filename,\ + lineno, file=file, line=line)) except IOError: pass ## file (probably __stderr__) is invalid, warning dropped. warnings.showwarning = idle_showwarning - def idle_formatwarning(message, category, filename, lineno): + def idle_formatwarning(message, category, filename, lineno, + file=None, line=None): """Format warnings the IDLE way""" s = "\nWarning (from warnings module):\n" s += ' File \"%s\", line %s\n' % (filename, lineno) - line = linecache.getline(filename, lineno).strip() + line = linecache.getline(filename, lineno).strip() \ + if line is None else line if line: s += " %s\n" % line s += "%s: %s\n>>> " % (category.__name__, message) diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py index 7827c740e66..abe94abc8b9 100644 --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -24,11 +24,13 @@ try: except ImportError: pass else: - def idle_formatwarning_subproc(message, category, filename, lineno): + def idle_formatwarning_subproc(message, category, filename, lineno, + file=None, line=None): """Format warnings the IDLE way""" s = "\nWarning (from warnings module):\n" s += ' File \"%s\", line %s\n' % (filename, lineno) - line = linecache.getline(filename, lineno).strip() + line = linecache.getline(filename, lineno).strip() \ + if line is None else line if line: s += " %s\n" % line s += "%s: %s\n" % (category.__name__, message)