Merged revisions 74446-74449 via svnmerge from
svn+ssh://pythondev/python/trunk

........
  r74446 | guilherme.polo | 2009-08-14 10:53:41 -0300 (Fri, 14 Aug 2009) | 1 line

  Issue #3344: Replace itertools.count by enumerate.
........
  r74447 | guilherme.polo | 2009-08-14 11:03:07 -0300 (Fri, 14 Aug 2009) | 1 line

  Issue #3926: Fix the usage of the new showwarnings and formatwarning.
........
  r74448 | guilherme.polo | 2009-08-14 11:36:45 -0300 (Fri, 14 Aug 2009) | 3 lines

  Issue #1135: Add the XView and YView mix-ins to avoid duplicating
  the xview* and yview* methods.
........
  r74449 | guilherme.polo | 2009-08-14 11:43:43 -0300 (Fri, 14 Aug 2009) | 1 line

  Clarifying Entry.selection_present's docstring.
........
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index c1e9e1e..a634962 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -3,7 +3,6 @@
 import re
 import string
 import imp
-from itertools import count
 from tkinter import *
 import tkinter.simpledialog as tkSimpleDialog
 import tkinter.messagebox as tkMessageBox
@@ -785,8 +784,8 @@
         for instance in self.top.instance_dict:
             menu = instance.recent_files_menu
             menu.delete(1, END)  # clear, and rebuild:
-            for i, file in zip(count(), rf_list):
-                file_name = file[0:-1]  # zap \n
+            for i, file_name in enumerate(rf_list):
+                file_name = file_name.rstrip()  # zap \n
                 # make unicode string to display non-ASCII chars correctly
                 ufile_name = self._filename_to_unicode(file_name)
                 callback = instance.__recent_file_callback(file_name)
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index 0136089..edc9334 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -55,20 +55,21 @@
 else:
     def idle_showwarning(message, category, filename, lineno,
                          file=None, line=None):
-        file = warning_stream
+        if file is None:
+            file = warning_stream
         try:
-            file.write(warnings.formatwarning(message, category, filename,\
+            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,
-                           file=None, line=None):
+    def idle_formatwarning(message, category, filename, lineno, 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() \
-            if line is None else line
+        if line is None:
+            line = linecache.getline(filename, lineno)
+        line = line.strip()
         if line:
             s += "    %s\n" % line
         s += "%s: %s\n>>> " % (category.__name__, message)
@@ -81,18 +82,17 @@
 
     Rather than repeating the linecache code, patch it to save the
     <pyshell#...> entries, call the original linecache.checkcache()
-    (which destroys them), and then restore the saved entries.
+    (skipping them), and then restore the saved entries.
 
     orig_checkcache is bound at definition time to the original
     method, allowing it to be patched.
-
     """
     cache = linecache.cache
     save = {}
-    for filename in cache:
-        if filename[:1] + filename[-1:] == '<>':
-            save[filename] = cache[filename]
-    orig_checkcache()
+    for key in list(cache):
+        if key[:1] + key[-1:] == '<>':
+            save[key] = cache.pop(key)
+    orig_checkcache(filename)
     cache.update(save)
 
 # Patch linecache.checkcache():
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index fd2cc09..25338ff 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -25,12 +25,13 @@
     pass
 else:
     def idle_formatwarning_subproc(message, category, filename, lineno,
-                                   file=None, line=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() \
-            if line is None else line
+        if line is None:
+            line = linecache.getline(filename, lineno)
+        line = line.strip()
         if line:
             s += "    %s\n" % line
         s += "%s: %s\n" % (category.__name__, message)