[Python-checkins] r74452 - in python/branches/tk_and_idle_maintenance: Doc/library/logging.rst Lib/idlelib/EditorWindow.py Lib/idlelib/PyShell.py Lib/idlelib/run.py
guilherme.polo
python-checkins at python.org
Fri Aug 14 19:27:36 CEST 2009
Author: guilherme.polo
Date: Fri Aug 14 19:27:35 2009
New Revision: 74452
Log:
Merged revisions 74445-74447 via svnmerge from
svn+ssh://pythondev/python/trunk
........
r74445 | vinay.sajip | 2009-08-14 08:33:54 -0300 (Fri, 14 Aug 2009) | 1 line
Added versionchanged notices for optional 'delay' parameter to file handler classes.
........
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.
........
Modified:
python/branches/tk_and_idle_maintenance/ (props changed)
python/branches/tk_and_idle_maintenance/Doc/library/logging.rst
python/branches/tk_and_idle_maintenance/Lib/idlelib/EditorWindow.py
python/branches/tk_and_idle_maintenance/Lib/idlelib/PyShell.py
python/branches/tk_and_idle_maintenance/Lib/idlelib/run.py
Modified: python/branches/tk_and_idle_maintenance/Doc/library/logging.rst
==============================================================================
--- python/branches/tk_and_idle_maintenance/Doc/library/logging.rst (original)
+++ python/branches/tk_and_idle_maintenance/Doc/library/logging.rst Fri Aug 14 19:27:35 2009
@@ -1627,6 +1627,8 @@
with that encoding. If *delay* is true, then file opening is deferred until the
first call to :meth:`emit`. By default, the file grows indefinitely.
+ .. versionchanged:: 2.6
+ *delay* was added.
.. method:: close()
@@ -1696,6 +1698,9 @@
with that encoding. If *delay* is true, then file opening is deferred until the
first call to :meth:`emit`. By default, the file grows indefinitely.
+ .. versionchanged:: 2.6
+ *delay* was added.
+
.. method:: emit(record)
@@ -1733,6 +1738,8 @@
:file:`app.log.1`, :file:`app.log.2`, etc. exist, then they are renamed to
:file:`app.log.2`, :file:`app.log.3` etc. respectively.
+ .. versionchanged:: 2.6
+ *delay* was added.
.. method:: doRollover()
@@ -1792,6 +1799,11 @@
one is deleted. The deletion logic uses the interval to determine which
files to delete, so changing the interval may leave old files lying around.
+ If *delay* is true, then file opening is deferred until the first call to
+ :meth:`emit`.
+
+ .. versionchanged:: 2.6
+ *delay* was added.
.. method:: doRollover()
Modified: python/branches/tk_and_idle_maintenance/Lib/idlelib/EditorWindow.py
==============================================================================
--- python/branches/tk_and_idle_maintenance/Lib/idlelib/EditorWindow.py (original)
+++ python/branches/tk_and_idle_maintenance/Lib/idlelib/EditorWindow.py Fri Aug 14 19:27:35 2009
@@ -2,7 +2,6 @@
import os
import re
import imp
-from itertools import count
from Tkinter import *
import tkSimpleDialog
import tkMessageBox
@@ -818,8 +817,8 @@
for instance in self.top.instance_dict.keys():
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)
Modified: python/branches/tk_and_idle_maintenance/Lib/idlelib/PyShell.py
==============================================================================
--- python/branches/tk_and_idle_maintenance/Lib/idlelib/PyShell.py (original)
+++ python/branches/tk_and_idle_maintenance/Lib/idlelib/PyShell.py Fri Aug 14 19:27:35 2009
@@ -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.keys():
- 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():
Modified: python/branches/tk_and_idle_maintenance/Lib/idlelib/run.py
==============================================================================
--- python/branches/tk_and_idle_maintenance/Lib/idlelib/run.py (original)
+++ python/branches/tk_and_idle_maintenance/Lib/idlelib/run.py Fri Aug 14 19:27:35 2009
@@ -26,12 +26,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)
More information about the Python-checkins
mailing list