]> granicus.if.org Git - python/commitdiff
use new showwarnings signature for idle #3391
authorBenjamin Peterson <benjamin@python.org>
Thu, 16 Oct 2008 19:40:14 +0000 (19:40 +0000)
committerBenjamin Peterson <benjamin@python.org>
Thu, 16 Oct 2008 19:40:14 +0000 (19:40 +0000)
Lib/idlelib/PyShell.py
Lib/idlelib/run.py

index a17f81ff402e750d5fa021d9b2a0f7564152b443..c1b98a059f4a84fe1f65a81fcbe3d0eaefe5faee 100644 (file)
@@ -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)
index 35a50314ca8c642db15ac2ee9ef246f38ffb48ae..abe94abc8b9c44e9ba6ea1a25d484b8e209954bb 100644 (file)
@@ -25,11 +25,12 @@ except ImportError:
     pass
 else:
     def idle_formatwarning_subproc(message, category, filename, lineno,
-                                   line=None):
+                                   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)