[Python-checkins] r63669 - in python/branches/tlee-ast-optimize: Doc/library/anydbm.rst Doc/library/dbhash.rst Doc/library/dbm.rst Doc/library/docxmlrpcserver.rst Doc/library/dumbdbm.rst Doc/library/dummy_thread.rst Doc/library/gdbm.rst Doc/library/simplexmlrpcserver.rst Doc/library/string.rst Doc/library/thread.rst Doc/library/whichdb.rst Doc/library/xmlrpclib.rst Doc/tutorial/controlflow.rst Doc/tutorial/datastructures.rst Doc/tutorial/errors.rst Doc/tutorial/floatingpoint.rst Doc/tutorial/inputoutput.rst Doc/tutorial/introduction.rst Doc/tutorial/stdlib2.rst Lib/bsddb/__init__.py Lib/gzip.py Lib/lib2to3 Lib/lib2to3/fixes/fix_imports.py Lib/lib2to3/pgen2/driver.py Lib/lib2to3/tests/test_fixers.py Lib/test/test_bsddb.py Lib/test/test_gzip.py Misc/NEWS Tools/msi/msi.py Tools/msi/msilib.py

thomas.lee python-checkins at python.org
Mon May 26 13:42:08 CEST 2008


Author: thomas.lee
Date: Mon May 26 13:42:06 2008
New Revision: 63669

Log:
Merged revisions 63612-63668 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

................
  r63614 | georg.brandl | 2008-05-25 18:07:37 +1000 (Sun, 25 May 2008) | 2 lines
  
  #2959: allow multiple close() calls for GzipFile.
................
  r63617 | gregory.p.smith | 2008-05-25 18:28:29 +1000 (Sun, 25 May 2008) | 6 lines
  
  Fix issue2669: bsddb simple/legacy interface iteration silently fails
  when database changes size during iteration.
  
  It now behaves like a dictionary, the next attempt to get a value from
  the iterator after the database has changed size will raise a RuntimeError.
................
  r63618 | gregory.p.smith | 2008-05-25 18:32:04 +1000 (Sun, 25 May 2008) | 2 lines
  
  note about r63617
................
  r63625 | martin.v.loewis | 2008-05-25 21:56:23 +1000 (Sun, 25 May 2008) | 1 line
  
  Include all licenses of the packages that we include.
................
  r63630 | georg.brandl | 2008-05-25 22:34:57 +1000 (Sun, 25 May 2008) | 2 lines
  
  Add renaming notices to thread and dummy_thread.
................
  r63634 | martin.v.loewis | 2008-05-26 00:58:01 +1000 (Mon, 26 May 2008) | 81 lines
  
  Merged revisions 62647-63633 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
  
  ........
    r63047 | alexandre.vassalotti | 2008-05-11 11:03:24 +0200 (So, 11 Mai 2008) | 2 lines
    
    Added import fixer for copy_reg rename.
  ........
    r63081 | alexandre.vassalotti | 2008-05-11 22:06:36 +0200 (So, 11 Mai 2008) | 2 lines
    
    Added import fixer for Queue rename.
  ........
    r63090 | alexandre.vassalotti | 2008-05-11 22:38:16 +0200 (So, 11 Mai 2008) | 2 lines
    
    Added import fixer for PixMapWrapper rename.
  ........
    r63141 | alexandre.vassalotti | 2008-05-12 04:42:03 +0200 (Mo, 12 Mai 2008) | 5 lines
    
    Added fixer for SocketServer renaming.
    Removed PixMapWrapper fixer, since the module is actually pending
    removal.
  ........
    r63252 | alexandre.vassalotti | 2008-05-15 01:10:20 +0200 (Do, 15 Mai 2008) | 2 lines
    
    Added fixer for ConfigParser rename.
  ........
    r63321 | collin.winter | 2008-05-15 19:42:58 +0200 (Do, 15 Mai 2008) | 1 line
    
    Add a missing comma. Fixes issue 2866.
  ........
    r63356 | alexandre.vassalotti | 2008-05-16 08:55:44 +0200 (Fr, 16 Mai 2008) | 4 lines
    
    Added new tests for fix_imports.
    Added refactoring support of from-import statements of the style:
      from foo import bar, baz
  ........
    r63362 | alexandre.vassalotti | 2008-05-16 09:17:53 +0200 (Fr, 16 Mai 2008) | 2 lines
    
    Added the repr module import fixer. 
  ........
    r63456 | georg.brandl | 2008-05-18 21:51:18 +0200 (So, 18 Mai 2008) | 2 lines
    
    #2908: fixers for Tkinter rename.
  ........
    r63461 | georg.brandl | 2008-05-18 23:00:20 +0200 (So, 18 Mai 2008) | 2 lines
    
    Fix for last patch.
  ........
    r63525 | alexandre.vassalotti | 2008-05-21 23:43:29 +0200 (Mi, 21 Mai 2008) | 4 lines
    
    Add missing comma in fix_imports.
    
    Bug caught by Quentin Gallet-Gilles.
  ........
    r63532 | brett.cannon | 2008-05-22 05:02:43 +0200 (Do, 22 Mai 2008) | 4 lines
    
    When testing fix_imports, no need to only test a subset of input; test it all!
    
    Do all revisions to the sandbox need to be manually applied to the trunk?
  ........
    r63533 | brett.cannon | 2008-05-22 05:16:45 +0200 (Do, 22 Mai 2008) | 1 line
    
    Add _markupbase to the import fixer.
  ........
    r63612 | georg.brandl | 2008-05-25 09:56:59 +0200 (So, 25 Mai 2008) | 2 lines
    
    Add fixer for _winreg rename.
  ........
    r63627 | georg.brandl | 2008-05-25 14:30:10 +0200 (So, 25 Mai 2008) | 2 lines
    
    Add fixer entry for the thread module.
  ........
    r63629 | georg.brandl | 2008-05-25 14:34:13 +0200 (So, 25 Mai 2008) | 2 lines
    
    Fixer entry for dummy_thread.
  ........
    r63633 | martin.v.loewis | 2008-05-25 16:52:41 +0200 (So, 25 Mai 2008) | 2 lines
    
    Temporarily disable Test_imports.
  ........
................
  r63638 | martin.v.loewis | 2008-05-26 02:37:34 +1000 (Mon, 26 May 2008) | 1 line
  
  Create grammar pickle files on installation; remove them on uninstallation.
................
  r63644 | martin.v.loewis | 2008-05-26 03:19:22 +1000 (Mon, 26 May 2008) | 10 lines
  
  Merged revisions 63634-63643 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
  
  ........
    r63643 | martin.v.loewis | 2008-05-25 19:18:21 +0200 (So, 25 Mai 2008) | 3 lines
    
    Don't abort on IOErrors caused by saving pickle files.
    Fixes #2938.
  ........
................
  r63649 | benjamin.peterson | 2008-05-26 06:05:52 +1000 (Mon, 26 May 2008) | 2 lines
  
  rename the section about new formatting 'new-string-formatting'
................
  r63655 | benjamin.peterson | 2008-05-26 10:54:22 +1000 (Mon, 26 May 2008) | 2 lines
  
  update the tutorial to use str.format
................
  r63660 | georg.brandl | 2008-05-26 20:22:15 +1000 (Mon, 26 May 2008) | 2 lines
  
  Add renaming notices to 2.6 dbm module docs.
................
  r63665 | georg.brandl | 2008-05-26 20:47:43 +1000 (Mon, 26 May 2008) | 2 lines
  
  Add renaming notices to xmlrpc modules.
................


Modified:
   python/branches/tlee-ast-optimize/   (props changed)
   python/branches/tlee-ast-optimize/Doc/library/anydbm.rst
   python/branches/tlee-ast-optimize/Doc/library/dbhash.rst
   python/branches/tlee-ast-optimize/Doc/library/dbm.rst
   python/branches/tlee-ast-optimize/Doc/library/docxmlrpcserver.rst
   python/branches/tlee-ast-optimize/Doc/library/dumbdbm.rst
   python/branches/tlee-ast-optimize/Doc/library/dummy_thread.rst
   python/branches/tlee-ast-optimize/Doc/library/gdbm.rst
   python/branches/tlee-ast-optimize/Doc/library/simplexmlrpcserver.rst
   python/branches/tlee-ast-optimize/Doc/library/string.rst
   python/branches/tlee-ast-optimize/Doc/library/thread.rst
   python/branches/tlee-ast-optimize/Doc/library/whichdb.rst
   python/branches/tlee-ast-optimize/Doc/library/xmlrpclib.rst
   python/branches/tlee-ast-optimize/Doc/tutorial/controlflow.rst
   python/branches/tlee-ast-optimize/Doc/tutorial/datastructures.rst
   python/branches/tlee-ast-optimize/Doc/tutorial/errors.rst
   python/branches/tlee-ast-optimize/Doc/tutorial/floatingpoint.rst
   python/branches/tlee-ast-optimize/Doc/tutorial/inputoutput.rst
   python/branches/tlee-ast-optimize/Doc/tutorial/introduction.rst
   python/branches/tlee-ast-optimize/Doc/tutorial/stdlib2.rst
   python/branches/tlee-ast-optimize/Lib/bsddb/__init__.py
   python/branches/tlee-ast-optimize/Lib/gzip.py
   python/branches/tlee-ast-optimize/Lib/lib2to3/   (props changed)
   python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports.py
   python/branches/tlee-ast-optimize/Lib/lib2to3/pgen2/driver.py
   python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py
   python/branches/tlee-ast-optimize/Lib/test/test_bsddb.py
   python/branches/tlee-ast-optimize/Lib/test/test_gzip.py
   python/branches/tlee-ast-optimize/Misc/NEWS
   python/branches/tlee-ast-optimize/Tools/msi/msi.py
   python/branches/tlee-ast-optimize/Tools/msi/msilib.py

Modified: python/branches/tlee-ast-optimize/Doc/library/anydbm.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/anydbm.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/anydbm.rst	Mon May 26 13:42:06 2008
@@ -1,4 +1,3 @@
-
 :mod:`anydbm` --- Generic access to DBM-style databases
 =======================================================
 
@@ -6,6 +5,11 @@
    :synopsis: Generic interface to DBM-style database modules.
 
 
+.. note::
+   The :mod:`anydbm` module has been renamed to :mod:`dbm` in Python 3.0.  The
+   :term:`2to3` tool will automatically adapt imports when converting your
+   sources to 3.0.
+
 .. index::
    module: dbhash
    module: bsddb

Modified: python/branches/tlee-ast-optimize/Doc/library/dbhash.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/dbhash.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/dbhash.rst	Mon May 26 13:42:06 2008
@@ -1,4 +1,3 @@
-
 :mod:`dbhash` --- DBM-style interface to the BSD database library
 =================================================================
 
@@ -6,6 +5,10 @@
    :synopsis: DBM-style interface to the BSD database library.
 .. sectionauthor:: Fred L. Drake, Jr. <fdrake at acm.org>
 
+.. note::
+   The :mod:`dbhash` module has been renamed to :mod:`dbm.bsd` in Python 3.0.
+   The :term:`2to3` tool will automatically adapt imports when converting your
+   sources to 3.0.
 
 .. index:: module: bsddb
 

Modified: python/branches/tlee-ast-optimize/Doc/library/dbm.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/dbm.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/dbm.rst	Mon May 26 13:42:06 2008
@@ -1,4 +1,3 @@
-
 :mod:`dbm` --- Simple "database" interface
 ==========================================
 
@@ -6,6 +5,11 @@
    :platform: Unix
    :synopsis: The standard "database" interface, based on ndbm.
 
+.. note::
+   The :mod:`dbm` module has been renamed to :mod:`dbm.ndbm` in Python 3.0.  The
+   :term:`2to3` tool will automatically adapt imports when converting your
+   sources to 3.0.
+
 
 The :mod:`dbm` module provides an interface to the Unix "(n)dbm" library.  Dbm
 objects behave like mappings (dictionaries), except that keys and values are

Modified: python/branches/tlee-ast-optimize/Doc/library/docxmlrpcserver.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/docxmlrpcserver.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/docxmlrpcserver.rst	Mon May 26 13:42:06 2008
@@ -1,4 +1,3 @@
-
 :mod:`DocXMLRPCServer` --- Self-documenting XML-RPC server
 ==========================================================
 
@@ -7,6 +6,11 @@
 .. moduleauthor:: Brian Quinlan <brianq at activestate.com>
 .. sectionauthor:: Brian Quinlan <brianq at activestate.com>
 
+.. note::
+   The :mod:`DocXMLRPCServer` module has been merged into :mod:`xmlrpc.server`
+   in Python 3.0.  The :term:`2to3` tool will automatically adapt imports when
+   converting your sources to 3.0.
+
 
 .. versionadded:: 2.3
 

Modified: python/branches/tlee-ast-optimize/Doc/library/dumbdbm.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/dumbdbm.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/dumbdbm.rst	Mon May 26 13:42:06 2008
@@ -1,10 +1,13 @@
-
 :mod:`dumbdbm` --- Portable DBM implementation
 ==============================================
 
 .. module:: dumbdbm
    :synopsis: Portable implementation of the simple DBM interface.
 
+.. note::
+   The :mod:`dumbdbm` module has been renamed to :mod:`dbm.dumb` in Python 3.0.
+   The :term:`2to3` tool will automatically adapt imports when converting your
+   sources to 3.0.
 
 .. index:: single: databases
 

Modified: python/branches/tlee-ast-optimize/Doc/library/dummy_thread.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/dummy_thread.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/dummy_thread.rst	Mon May 26 13:42:06 2008
@@ -1,10 +1,15 @@
-
 :mod:`dummy_thread` --- Drop-in replacement for the :mod:`thread` module
 ========================================================================
 
 .. module:: dummy_thread
    :synopsis: Drop-in replacement for the thread module.
 
+.. note::
+   The :mod:`dummy_thread` module has been renamed to :mod:`_dummy_thread` in
+   Python 3.0.  The :term:`2to3` tool will automatically adapt imports when
+   converting your sources to 3.0; however, you should consider using the
+   high-lever :mod:`dummy_threading` module instead.
+
 
 This module provides a duplicate interface to the :mod:`thread` module.  It is
 meant to be imported when the :mod:`thread` module is not provided on a

Modified: python/branches/tlee-ast-optimize/Doc/library/gdbm.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/gdbm.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/gdbm.rst	Mon May 26 13:42:06 2008
@@ -1,4 +1,3 @@
-
 :mod:`gdbm` --- GNU's reinterpretation of dbm
 =============================================
 
@@ -6,6 +5,11 @@
    :platform: Unix
    :synopsis: GNU's reinterpretation of dbm.
 
+.. note::
+   The :mod:`gdbm` module has been renamed to :mod:`dbm.gnu` in Python 3.0.  The
+   :term:`2to3` tool will automatically adapt imports when converting your
+   sources to 3.0.
+
 
 .. index:: module: dbm
 

Modified: python/branches/tlee-ast-optimize/Doc/library/simplexmlrpcserver.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/simplexmlrpcserver.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/simplexmlrpcserver.rst	Mon May 26 13:42:06 2008
@@ -1,4 +1,3 @@
-
 :mod:`SimpleXMLRPCServer` --- Basic XML-RPC server
 ==================================================
 
@@ -7,6 +6,11 @@
 .. moduleauthor:: Brian Quinlan <brianq at activestate.com>
 .. sectionauthor:: Fred L. Drake, Jr. <fdrake at acm.org>
 
+.. note::
+   The :mod:`SimpleXMLRPCServer` module has been merged into
+   :mod:`xmlrpc.server` in Python 3.0.  The :term:`2to3` tool will automatically
+   adapt imports when converting your sources to 3.0.
+
 
 .. versionadded:: 2.2
 

Modified: python/branches/tlee-ast-optimize/Doc/library/string.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/string.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/string.rst	Mon May 26 13:42:06 2008
@@ -103,16 +103,16 @@
    :func:`strip` and :func:`split` is undefined.
 
 
-.. _string-formatting:
+.. _new-string-formatting:
 
 String Formatting
 -----------------
 
 Starting in Python 2.6, the built-in str and unicode classes provide the ability
-to do complex variable substitutions and value formatting via the :func:`format`
-method described in :pep:`3101`.  The :class:`Formatter` class in the
-:mod:`string` module allows you to create and customize your own string
-formatting behaviors using the same implementation as the built-in
+to do complex variable substitutions and value formatting via the
+:meth:`str.format` method described in :pep:`3101`.  The :class:`Formatter`
+class in the :mod:`string` module allows you to create and customize your own
+string formatting behaviors using the same implementation as the built-in
 :meth:`format` method.
 
 .. class:: Formatter

Modified: python/branches/tlee-ast-optimize/Doc/library/thread.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/thread.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/thread.rst	Mon May 26 13:42:06 2008
@@ -1,10 +1,15 @@
-
 :mod:`thread` --- Multiple threads of control
 =============================================
 
 .. module:: thread
    :synopsis: Create multiple threads of control within one interpreter.
 
+.. note::
+   The :mod:`thread` module has been renamed to :mod:`_thread` in Python 3.0.
+   The :term:`2to3` tool will automatically adapt imports when converting your
+   sources to 3.0; however, you should consider using the high-lever
+   :mod:`threading` module instead.
+
 
 .. index::
    single: light-weight processes

Modified: python/branches/tlee-ast-optimize/Doc/library/whichdb.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/whichdb.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/whichdb.rst	Mon May 26 13:42:06 2008
@@ -1,10 +1,14 @@
-
 :mod:`whichdb` --- Guess which DBM module created a database
 ============================================================
 
 .. module:: whichdb
    :synopsis: Guess which DBM-style module created a given database.
 
+.. note::
+   The :mod:`whichdb` module's only function has been put into the :mod:`dbm`
+   module in Python 3.0.  The :term:`2to3` tool will automatically adapt imports
+   when converting your sources to 3.0.
+
 
 The single function in this module attempts to guess which of the several simple
 database modules available--\ :mod:`dbm`, :mod:`gdbm`, or :mod:`dbhash`\

Modified: python/branches/tlee-ast-optimize/Doc/library/xmlrpclib.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/xmlrpclib.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/xmlrpclib.rst	Mon May 26 13:42:06 2008
@@ -6,6 +6,11 @@
 .. moduleauthor:: Fredrik Lundh <fredrik at pythonware.com>
 .. sectionauthor:: Eric S. Raymond <esr at snark.thyrsus.com>
 
+.. note::
+   The :mod:`xmlrpclib` module has been renamed to :mod:`xmlrpc.client` in
+   Python 3.0.  The :term:`2to3` tool will automatically adapt imports when
+   converting your sources to 3.0.
+
 
 .. XXX Not everything is documented yet.  It might be good to describe
    Marshaller, Unmarshaller, getparser, dumps, loads, and Transport.

Modified: python/branches/tlee-ast-optimize/Doc/tutorial/controlflow.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/tutorial/controlflow.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/tutorial/controlflow.rst	Mon May 26 13:42:06 2008
@@ -445,8 +445,8 @@
 up in a tuple.  Before the variable number of arguments, zero or more normal
 arguments may occur. ::
 
-   def fprintf(file, format, *args):
-       file.write(format % args)
+   def fprintf(file, template, *args):
+       file.write(template.format(args))
 
 
 .. _tut-unpacking-arguments:

Modified: python/branches/tlee-ast-optimize/Doc/tutorial/datastructures.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/tutorial/datastructures.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/tutorial/datastructures.rst	Mon May 26 13:42:06 2008
@@ -550,7 +550,7 @@
    >>> questions = ['name', 'quest', 'favorite color']
    >>> answers = ['lancelot', 'the holy grail', 'blue']
    >>> for q, a in zip(questions, answers):
-   ...     print 'What is your %s?  It is %s.' % (q, a)
+   ...     print 'What is your {0}?  It is {1}.'.format(q, a)
    ...	
    What is your name?  It is lancelot.
    What is your quest?  It is the holy grail.

Modified: python/branches/tlee-ast-optimize/Doc/tutorial/errors.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/tutorial/errors.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/tutorial/errors.rst	Mon May 26 13:42:06 2008
@@ -132,7 +132,7 @@
        s = f.readline()
        i = int(s.strip())
    except IOError as (errno, strerror):
-       print "I/O error(%s): %s" % (errno, strerror)
+       print "I/O error({0}): {1}".format(errno, strerror)
    except ValueError:
        print "Could not convert data to an integer."
    except:

Modified: python/branches/tlee-ast-optimize/Doc/tutorial/floatingpoint.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/tutorial/floatingpoint.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/tutorial/floatingpoint.rst	Mon May 26 13:42:06 2008
@@ -132,9 +132,8 @@
 While pathological cases do exist, for most casual use of floating-point
 arithmetic you'll see the result you expect in the end if you simply round the
 display of your final results to the number of decimal digits you expect.
-:func:`str` usually suffices, and for finer control see the discussion of
-Python's ``%`` format operator: the ``%g``, ``%f`` and ``%e`` format codes
-supply flexible and easy ways to round float results for display.
+:func:`str` usually suffices, and for finer control see the :meth:`str.format`
+method's format specifiers in :ref:`formatstrings`.
 
 
 .. _tut-fp-error:

Modified: python/branches/tlee-ast-optimize/Doc/tutorial/inputoutput.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/tutorial/inputoutput.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/tutorial/inputoutput.rst	Mon May 26 13:42:06 2008
@@ -27,16 +27,13 @@
 concatenation operations you can create any layout you can imagine.  The
 standard module :mod:`string` contains some useful operations for padding
 strings to a given column width; these will be discussed shortly.  The second
-way is to use the ``%`` operator with a string as the left argument.  The ``%``
-operator interprets the left argument much like a :cfunc:`sprintf`\ -style
-format string to be applied to the right argument, and returns the string
-resulting from this formatting operation.
+way is to use the :meth:`str.format` method.
 
 One question remains, of course: how do you convert values to strings? Luckily,
 Python has ways to convert any value to a string: pass it to the :func:`repr`
 or :func:`str` functions.  Reverse quotes (``````) are equivalent to
-:func:`repr`, but they are no longer used in modern Python code and will likely
-not be in future versions of the language.
+:func:`repr`, but they are no longer used in modern Python code and are removed
+in future versions of the language.
 
 The :func:`str` function is meant to return representations of values which are
 fairly human-readable, while :func:`repr` is meant to generate representations
@@ -94,7 +91,7 @@
    10 100 1000
 
    >>> for x in range(1,11):
-   ...     print '%2d %3d %4d' % (x, x*x, x*x*x)
+   ...     print '{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x)
    ... 
     1   1    1
     2   4    8
@@ -129,42 +126,91 @@
    >>> '3.14159265359'.zfill(5)
    '3.14159265359'
 
-Using the ``%`` operator looks like this::
+Basic usage of the :meth:`str.format` method looks like this::
+
+   >>> print 'We are the {0} who say "{1}!"'.format('knights', 'Ni')
+   We are the knights who say "Ni!"
+
+The brackets and characters within them (called format fields) are replaced with
+the objects passed into the format method.  The number in the brackets refers to
+the position of the object passed into the format method. ::
+
+   >>> print '{0} and {1}'.format('spam', 'eggs')
+   spam and eggs
+   >>> print '{1} and {0}'.format('spam', 'eggs')
+   eggs and spam
+
+If keyword arguments are used in the format method, their values are referred to
+by using the name of the argument. ::
+
+   >>> print 'This {food} is {adjective}.'.format(food='spam', adjective='absolutely horrible')
+   This spam is absolutely horrible.
+
+Positional and keyword arguments can be arbitrarily combined::
+
+   >>> print 'The story of {0}, {1}, and {other}.'.format('Bill', 'Manfred', other='Georg')
+   The story of Bill, Manfred, and Georg.
+
+An optional ``':``` and format specifier can follow the field name. This also
+greater control over how the value is formatted.  The following example
+truncates the Pi to three places after the decimal.
 
    >>> import math
-   >>> print 'The value of PI is approximately %5.3f.' % math.pi
+   >>> print 'The value of PI is approximately {0:.3f}.'.format(math.pi)
    The value of PI is approximately 3.142.
 
-If there is more than one format in the string, you need to pass a tuple as
-right operand, as in this example::
+Passing an integer after the ``':'`` will cause that field to be a minimum
+number of characters wide.  This is useful for making tables pretty.::
 
    >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678}
    >>> for name, phone in table.items():
-   ...     print '%-10s ==> %10d' % (name, phone)
+   ...     print '{0:10} ==> {1:10d}'.format(name, phone)
    ... 
    Jack       ==>       4098
    Dcab       ==>       7678
    Sjoerd     ==>       4127
 
-Most formats work exactly as in C and require that you pass the proper type;
-however, if you don't you get an exception, not a core dump. The ``%s`` format
-is more relaxed: if the corresponding argument is not a string object, it is
-converted to string using the :func:`str` built-in function.  Using ``*`` to
-pass the width or precision in as a separate (integer) argument is supported.
-The C formats ``%n`` and ``%p`` are not supported.
-
 If you have a really long format string that you don't want to split up, it
 would be nice if you could reference the variables to be formatted by name
-instead of by position.  This can be done by using form ``%(name)format``, as
-shown here::
+instead of by position.  This can be done by simply passing the dict and using
+square brackets ``'[]'`` to access the keys ::
+
+   >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}
+   >>> print 'Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d}; Dcab: {0[Dcab]:d}'.format(table)
+   Jack: 4098; Sjoerd: 4127; Dcab: 8637678
+
+This could also be done by passing the table as keyword arguments with the '**'
+notation.::
 
    >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}
-   >>> print 'Jack: %(Jack)d; Sjoerd: %(Sjoerd)d; Dcab: %(Dcab)d' % table
+   >>> print 'Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: {Dcab:d}'.format(**table)
    Jack: 4098; Sjoerd: 4127; Dcab: 8637678
 
 This is particularly useful in combination with the new built-in :func:`vars`
 function, which returns a dictionary containing all local variables.
 
+For a complete overview of string formating with :meth:`str.format`, see
+:ref:`formatstrings`.
+
+
+Old string formatting
+---------------------
+
+The ``%`` operator can also be used for string formatting. It interprets the
+left argument much like a :cfunc:`sprintf`\ -style format string to be applied
+to the right argument, and returns the string resulting from this formatting
+operation. For example::
+
+   >>> import math
+   >>> print 'The value of PI is approximately %5.3f.' % math.pi
+   The value of PI is approximately 3.142.
+
+Since :meth:`str.format` is quite new, a lot of Python code still uses the ``%``
+operator. However, because this old style of formatting will eventually removed
+from the language :meth:`str.format` should generally be used.
+
+More information can be found in the :ref:`string-formatting` section.
+
 
 .. _tut-files:
 

Modified: python/branches/tlee-ast-optimize/Doc/tutorial/introduction.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/tutorial/introduction.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/tutorial/introduction.rst	Mon May 26 13:42:06 2008
@@ -372,9 +372,13 @@
       Both strings and Unicode strings support a large number of methods for
       basic transformations and searching.
 
+   :ref:`new-string-formatting`
+      Information about string formatting with :meth:`str.format` is described
+      here.
+
    :ref:`string-formatting`
-      The formatting operations invoked when strings and Unicode strings are the
-      left operand of the ``%`` operator are described in more detail here.
+      The old formatting operations invoked when strings and Unicode strings are
+      the left operand of the ``%`` operator are described in more detail here.
 
 
 .. _tut-unicodestrings:

Modified: python/branches/tlee-ast-optimize/Doc/tutorial/stdlib2.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/tutorial/stdlib2.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/tutorial/stdlib2.rst	Mon May 26 13:42:06 2008
@@ -116,7 +116,7 @@
    >>> for i, filename in enumerate(photofiles):
    ...     base, ext = os.path.splitext(filename)
    ...     newname = t.substitute(d=date, n=i, f=ext)
-   ...     print '%s --> %s' % (filename, newname)
+   ...     print '{0} --> {1}'.format(filename, newname)
 
    img_1074.jpg --> Ashley_0.jpg
    img_1076.jpg --> Ashley_1.jpg

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/__init__.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/__init__.py	Mon May 26 13:42:06 2008
@@ -33,7 +33,7 @@
 #----------------------------------------------------------------------
 
 
-"""Support for Berkeley DB 3.3 through 4.6 with a simple interface.
+"""Support for Berkeley DB 4.x with a simple interface.
 
 For the full featured object oriented interface use the bsddb.db module
 instead.  It mirrors the Oracle Berkeley DB C API.
@@ -66,13 +66,8 @@
 
 import sys, os
 
-# for backwards compatibility with python versions older than 2.3, the
-# iterator interface is dynamically defined and added using a mixin
-# class.  old python can't tokenize it due to the yield keyword.
-if sys.version >= '2.3':
-    import UserDict
-    from weakref import ref
-    exec """
+import UserDict
+from weakref import ref
 class _iter_mixin(UserDict.DictMixin):
     def _make_iter_cursor(self):
         cur = _DeadlockWrap(self.db.cursor)
@@ -87,67 +82,80 @@
         return lambda ref: self._cursor_refs.pop(key, None)
 
     def __iter__(self):
+        self._kill_iteration = False
+        self._in_iter += 1
         try:
-            cur = self._make_iter_cursor()
+            try:
+                cur = self._make_iter_cursor()
 
-            # FIXME-20031102-greg: race condition.  cursor could
-            # be closed by another thread before this call.
+                # FIXME-20031102-greg: race condition.  cursor could
+                # be closed by another thread before this call.
 
-            # since we're only returning keys, we call the cursor
-            # methods with flags=0, dlen=0, dofs=0
-            key = _DeadlockWrap(cur.first, 0,0,0)[0]
-            yield key
-
-            next = cur.next
-            while 1:
-                try:
-                    key = _DeadlockWrap(next, 0,0,0)[0]
-                    yield key
-                except _bsddb.DBCursorClosedError:
-                    cur = self._make_iter_cursor()
-                    # FIXME-20031101-greg: race condition.  cursor could
-                    # be closed by another thread before this call.
-                    _DeadlockWrap(cur.set, key,0,0,0)
-                    next = cur.next
-        except _bsddb.DBNotFoundError:
-            return
-        except _bsddb.DBCursorClosedError:
-            # the database was modified during iteration.  abort.
-            return
+                # since we're only returning keys, we call the cursor
+                # methods with flags=0, dlen=0, dofs=0
+                key = _DeadlockWrap(cur.first, 0,0,0)[0]
+                yield key
+
+                next = cur.next
+                while 1:
+                    try:
+                        key = _DeadlockWrap(next, 0,0,0)[0]
+                        yield key
+                    except _bsddb.DBCursorClosedError:
+                        if self._kill_iteration:
+                            raise RuntimeError('Database changed size '
+                                               'during iteration.')
+                        cur = self._make_iter_cursor()
+                        # FIXME-20031101-greg: race condition.  cursor could
+                        # be closed by another thread before this call.
+                        _DeadlockWrap(cur.set, key,0,0,0)
+                        next = cur.next
+            except _bsddb.DBNotFoundError:
+                pass
+            except _bsddb.DBCursorClosedError:
+                # the database was modified during iteration.  abort.
+                pass
+        finally:
+            self._in_iter -= 1
 
     def iteritems(self):
         if not self.db:
             return
+        self._kill_iteration = False
+        self._in_iter += 1
         try:
-            cur = self._make_iter_cursor()
-
-            # FIXME-20031102-greg: race condition.  cursor could
-            # be closed by another thread before this call.
+            try:
+                cur = self._make_iter_cursor()
 
-            kv = _DeadlockWrap(cur.first)
-            key = kv[0]
-            yield kv
+                # FIXME-20031102-greg: race condition.  cursor could
+                # be closed by another thread before this call.
 
-            next = cur.next
-            while 1:
-                try:
-                    kv = _DeadlockWrap(next)
-                    key = kv[0]
-                    yield kv
-                except _bsddb.DBCursorClosedError:
-                    cur = self._make_iter_cursor()
-                    # FIXME-20031101-greg: race condition.  cursor could
-                    # be closed by another thread before this call.
-                    _DeadlockWrap(cur.set, key,0,0,0)
-                    next = cur.next
-        except _bsddb.DBNotFoundError:
-            return
-        except _bsddb.DBCursorClosedError:
-            # the database was modified during iteration.  abort.
-            return
-"""
-else:
-    class _iter_mixin: pass
+                kv = _DeadlockWrap(cur.first)
+                key = kv[0]
+                yield kv
+
+                next = cur.next
+                while 1:
+                    try:
+                        kv = _DeadlockWrap(next)
+                        key = kv[0]
+                        yield kv
+                    except _bsddb.DBCursorClosedError:
+                        if self._kill_iteration:
+                            raise RuntimeError('Database changed size '
+                                               'during iteration.')
+                        cur = self._make_iter_cursor()
+                        # FIXME-20031101-greg: race condition.  cursor could
+                        # be closed by another thread before this call.
+                        _DeadlockWrap(cur.set, key,0,0,0)
+                        next = cur.next
+            except _bsddb.DBNotFoundError:
+                pass
+            except _bsddb.DBCursorClosedError:
+                # the database was modified during iteration.  abort.
+                pass
+        finally:
+            self._in_iter -= 1
 
 
 class _DBWithCursor(_iter_mixin):
@@ -176,6 +184,8 @@
         # a collection of all DBCursor objects currently allocated
         # by the _iter_mixin interface.
         self._cursor_refs = {}
+        self._in_iter = 0
+        self._kill_iteration = False
 
     def __del__(self):
         self.close()
@@ -225,6 +235,8 @@
     def __setitem__(self, key, value):
         self._checkOpen()
         self._closeCursors()
+        if self._in_iter and key not in self:
+            self._kill_iteration = True
         def wrapF():
             self.db[key] = value
         _DeadlockWrap(wrapF)  # self.db[key] = value
@@ -232,6 +244,8 @@
     def __delitem__(self, key):
         self._checkOpen()
         self._closeCursors()
+        if self._in_iter and key in self:
+            self._kill_iteration = True
         def wrapF():
             del self.db[key]
         _DeadlockWrap(wrapF)  # del self.db[key]

Modified: python/branches/tlee-ast-optimize/Lib/gzip.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/gzip.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/gzip.py	Mon May 26 13:42:06 2008
@@ -306,6 +306,8 @@
             raise IOError, "Incorrect length of data produced"
 
     def close(self):
+        if self.fileobj is None:
+            return
         if self.mode == WRITE:
             self.fileobj.write(self.compress.flush())
             write32u(self.fileobj, self.crc)

Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports.py	Mon May 26 13:42:06 2008
@@ -14,10 +14,143 @@
 builtin_names = [name for name in dir(__builtin__)
                  if name not in ("__name__", "__doc__")]
 
+# XXX(alexandre): It would be possible to get the modules exports by fetching
+# XXX: their __all__ attribute. However, I fear that this would add an additional
+# XXX: overhead to the fixer.
 MAPPING = {"StringIO":  ("io", ["StringIO"]),
            "cStringIO": ("io", ["StringIO"]),
            "__builtin__" : ("builtins", builtin_names),
-          }
+           'copy_reg': ('copyreg', ['pickle',
+                                    'constructor',
+                                    'add_extension',
+                                    'remove_extension',
+                                    'clear_extension_cache']),
+           'Queue': ('queue', ['Empty', 'Full', 'Queue',
+                               'PriorityQueue', 'LifoQueue']),
+           'SocketServer': ('socketserver',
+                            ['TCPServer', 'UDPServer', 'BaseServer',
+                             'ForkingUDPServer', 'ForkingTCPServer',
+                             'ThreadingUDPServer', 'ThreadingTCPServer',
+                             'BaseRequestHandler', 'StreamRequestHandler',
+                             'DatagramRequestHandler', 'ThreadingMixIn',
+                             'ForkingMixIn', 'UnixStreamServer',
+                             'UnixDatagramServer', 'ThreadingUnixStreamServer',
+                             'ThreadingUnixDatagramServer']),
+           'ConfigParser': ('configparser',
+                            ['NoSectionError', 'DuplicateSectionError',
+                             'NoOptionError', 'InterpolationError',
+                             'InterpolationDepthError',
+                             'InterpolationSyntaxError',
+                             'ParsingError', 'MissingSectionHeaderError',
+                             'ConfigParser', 'SafeConfigParser',
+                             'RawConfigParser', 'DEFAULTSECT',
+                             'MAX_INTERPOLATION_DEPTH']),
+           'repr': ('reprlib', ['Repr', 'repr']),
+           'FileDialog': ('tkinter.filedialog',
+                          ['FileDialog', 'LoadFileDialog', 'SaveFileDialog']),
+           'tkFileDialog': ('tkinter.filedialog',
+                            ['Open', 'SaveAs', 'Directory', 'askopenfilename',
+                             'asksaveasfilename', 'askopenfilenames',
+                             'askopenfile', 'askopenfiles', 'asksaveasfile',
+                             'askdirectory']),
+           'SimpleDialog': ('tkinter.simpledialog', ['SimpleDialog']),
+           'tkSimpleDialog': ('tkinter.simpledialog',
+                              ['Dialog', 'askinteger', 'askfloat',
+                               'askstring']),
+           'tkColorChooser': ('tkinter.colorchooser', ['Chooser', 'askcolor']),
+           'tkCommonDialog': ('tkinter.commondialog', ['Dialog']),
+           'Dialog': ('tkinter.dialog', ['Dialog']),
+           'Tkdnd': ('tkinter.dnd', ['DndHandler']),
+           'tkFont': ('tkinter.font',
+                      ['nametofont', 'Font', 'families', 'names']),
+           'tkMessageBox': ('tkinter.messagebox',
+                            ['Message', 'showinfo', 'showwarning', 'showerror',
+                             'askquestion', 'askokcancel', 'askyesno',
+                             'askyesnocancel', 'askretrycancel']),
+           'ScrolledText': ('tkinter.scrolledtext', ['ScrolledText']),
+           'turtle': ('tkinter.turtle',
+                      ['RawPen', 'Pen', 'Turtle', 'degrees', 'radian', 'reset',
+                       'clear', 'tracer', 'forward', 'backward', 'left',
+                       'right', 'up', 'down', 'width', 'color', 'write', 'fill',
+                       'begin_fill', 'end_fill', 'circle', 'goto', 'heading',
+                       'setheading', 'position', 'window_width', 'setx', 'sety',
+                       'towards', 'done', 'delay', 'speed', 'setup', 'title']),
+           'Tkconstants': ('tkinter.constants',
+                           ['NO', 'FALSE', 'OFF', 'YES', 'TRUE', 'ON', 'N', 'S',
+                            'W', 'E', 'NW', 'SW', 'SE', 'NE', 'NS', 'EW',
+                            'NSEW', 'CENTER', 'NONE', 'X', 'Y', 'BOTH', 'LEFT',
+                            'TOP', 'RIGHT', 'BOTTOM', 'RAISED', 'SUNKEN',
+                            'FLAT', 'RIDGE', 'GROOVE', 'SOLID', 'HORIZONTAL',
+                            'VERTICAL', 'NUMERIC', 'CHAR', 'WORD', 'BASELINE',
+                            'INSIDE', 'OUTSIDE', 'SEL', 'SEL_FIRST', 'SEL_LAST',
+                            'END', 'INSERT', 'CURRENT', 'ANCHOR', 'ALL',
+                            'NORMAL', 'DISABLED', 'ACTIVE', 'HIDDEN', 'CASCADE',
+                            'CHECKBUTTON', 'COMMAND', 'RADIOBUTTON',
+                            'SEPARATOR', 'SINGLE', 'BROWSE', 'MULTIPLE',
+                            'EXTENDED', 'DOTBOX', 'UNDERLINE', 'PIESLICE',
+                            'CHORD', 'ARC', 'FIRST', 'LAST', 'BUTT',
+                            'PROJECTING', 'ROUND', 'BEVEL', 'MITTER', 'MOVETO',
+                            'SCROLL', 'UNITS', 'PAGES']),
+           'Tix': ('tkinter.tix',
+                   ['tixCommand', 'Tk', 'Form', 'TixWidget', 'TixSubWidget',
+                    'DisplayStyle', 'Balloon', 'ButtonBox', 'ComboBox',
+                    'Control', 'DirList', 'DirTree', 'DirSelectBox',
+                    'ExFileSelectBox', 'DirSelectDialog', 'ExFileSelectDialog',
+                    'FileSelectBox', 'FileSelectDialog', 'FileEntry', 'HList',
+                    'InputOnly', 'LabelEntry', 'LabelFrame', 'ListNoteBook',
+                    'Meter', 'NoteBook', 'OptionMenu', 'PanedWindow',
+                    'PopupMenu', 'ResizeHandle', 'ScrolledHList',
+                    'ScrolledListBox', 'ScrolledText', 'ScrolledTList',
+                    'ScrolledWindow', 'Select', 'Shell', 'DialogShell',
+                    'StdButtonBox', 'TList', 'Tree', 'CheckList', 'OptionName',
+                    'FileTypeList', 'Grid', 'ScrolledGrid']),
+           'Tkinter': ('tkinter',
+                       ['_flatten', 'TclError', 'TkVersion', 'TclVersion',
+                        'Variable', 'StringVar', 'IntVar', 'DoubleVar',
+                        'BooleanVar','mainloop', 'Tk', 'Tcl', 'Toplevel',
+                        'Button', 'Canvas', 'Checkbutton', 'Entry', 'Frame',
+                        'Label', 'Listbox', 'Menu', 'Menubutton',
+                        'Radiobutton', 'Scale', 'Scrollbar', 'Text',
+                        'OptionMenu', 'Image', 'PhotoImage', 'BitmapImage',
+                        'image_names', 'image_types', 'Spinbox', 'LabelFrame',
+                        'PanedWindow', 'Studbutton', 'Tributton']),
+           'markupbase': ('_markupbase', ['ParserBase']),
+           '_winreg': ('winreg', [
+               'CloseKey', 'ConnectRegistry', 'CreateKey', 'DeleteKey',
+               'DeleteValue', 'DisableReflectionKey', 'EnableReflectionKey',
+               'EnumKey', 'EnumValue', 'ExpandEnvironmentStrings', 'FlushKey',
+               'LoadKey', 'OpenKey', 'OpenKeyEx', 'QueryValue', 'QueryValueEx',
+               'QueryInfoKey', 'QueryReflectionKey', 'SaveKey', 'SetValue',
+               'SetValueEx', 'HKEY_CLASSES_ROOT', 'HKEY_CURRENT_USER',
+               'HKEY_LOCAL_MACHINE', 'HKEY_USERS', 'HKEY_PERFORMANCE_DATA',
+               'HKEY_CURRENT_CONFIG', 'HKEY_DYN_DATA', 'KEY_QUERY_VALUE',
+               'KEY_SET_VALUE', 'KEY_CREATE_SUB_KEY', 'KEY_ENUMERATE_SUB_KEYS',
+               'KEY_NOTIFY', 'KEY_CREATE_LINK', 'KEY_READ', 'KEY_WRITE',
+               'KEY_EXECUTE', 'KEY_ALL_ACCESS', 'KEY_WOW64_64KEY',
+               'KEY_WOW64_32KEY', 'REG_OPTION_RESERVED',
+               'REG_OPTION_NON_VOLATILE', 'REG_OPTION_VOLATILE',
+               'REG_OPTION_CREATE_LINK', 'REG_OPTION_BACKUP_RESTORE',
+               'REG_OPTION_OPEN_LINK', 'REG_LEGAL_OPTION',
+               'REG_CREATED_NEW_KEY', 'REG_OPENED_EXISTING_KEY',
+               'REG_WHOLE_HIVE_VOLATILE', 'REG_REFRESH_HIVE',
+               'REG_NO_LAZY_FLUSH', 'REG_NOTIFY_CHANGE_NAME',
+               'REG_NOTIFY_CHANGE_ATTRIBUTES', 'REG_NOTIFY_CHANGE_LAST_SET',
+               'REG_NOTIFY_CHANGE_SECURITY', 'REG_LEGAL_CHANGE_FILTER',
+               'REG_NONE', 'REG_SZ', 'REG_EXPAND_SZ', 'REG_BINARY', 'REG_DWORD',
+               'REG_DWORD_LITTLE_ENDIAN', 'REG_DWORD_BIG_ENDIAN', 'REG_LINK',
+               'REG_MULTI_SZ', 'REG_RESOURCE_LIST',
+               'REG_FULL_RESOURCE_DESCRIPTOR', 'REG_RESOURCE_REQUIREMENTS_LIST']),
+           'thread': ('_thread',
+                      ['LockType', '_local', 'allocate', 'allocate_lock',
+                       'error', 'exit', 'exit_thread', 'get_ident',
+                       'interrupt_main', 'stack_size', 'start_new',
+                       'start_new_thread']),
+           'dummy_thread': ('_dummy_thread',
+                      ['LockType', '_local', 'allocate', 'allocate_lock',
+                       'error', 'exit', 'exit_thread', 'get_ident',
+                       'interrupt_main', 'stack_size', 'start_new',
+                       'start_new_thread']),
+}
 
 
 def alternates(members):
@@ -34,7 +167,8 @@
                               | dotted_as_names< any* module=%r any* >) >
               """ % (old_module, old_module)
         yield """import_from< 'from' module_name=%r 'import'
-                   ( %s | import_as_name< %s 'as' any >) >
+                   ( %s | import_as_name< %s 'as' any > |
+                     import_as_names< any* >) >
               """ % (old_module, members, members)
         yield """import_from< 'from' module_name=%r 'import' star='*' >
               """ % old_module

Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/pgen2/driver.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/pgen2/driver.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/pgen2/driver.py	Mon May 26 13:42:06 2008
@@ -126,7 +126,10 @@
         g = pgen.generate_grammar(gt)
         if save:
             logger.info("Writing grammar tables to %s", gp)
-            g.dump(gp)
+            try:
+                g.dump(gp)
+            except IOError, e:
+                logger.info("Writing failed:"+str(e))
     else:
         g = grammar.Grammar()
         g.load(gp)

Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py	Mon May 26 13:42:06 2008
@@ -1405,14 +1405,12 @@
         s = "foo(xreadlines)"
         self.unchanged(s)
 
-class Test_imports(FixerTestCase):
+# Disable test, as it takes a too long time to run, and also
+# fails in 2.6.
+#class Test_imports(FixerTestCase):
+class Test_imports:
     fixer = "imports"
-
-    modules = {"StringIO":  ("io", ["StringIO"]),
-               "cStringIO": ("io", ["StringIO"]),
-               "__builtin__" : ("builtins", ["open", "Exception",
-                   "__debug__", "str"]),
-              }
+    from ..fixes.fix_imports import MAPPING as modules
 
     def test_import_module(self):
         for old, (new, members) in self.modules.items():
@@ -1434,6 +1432,13 @@
                 s = "from foo import %s" % member
                 self.unchanged(s)
 
+            b = "from %s import %s" % (old, ", ".join(members))
+            a = "from %s import %s" % (new, ", ".join(members))
+            self.check(b, a)
+
+            s = "from foo import %s" % ", ".join(members)
+            self.unchanged(s)
+
     def test_import_module_as(self):
         for old, (new, members) in self.modules.items():
             b = "import %s as foo_bar" % old
@@ -1481,6 +1486,16 @@
                     foo(%s, %s())
                     """ % (new, member, member, member)
                 self.check(b, a)
+            b = """
+                from %s import %s
+                foo(%s)
+                """ % (old, ", ".join(members), ", ".join(members))
+            a = """
+                from %s import %s
+                foo(%s)
+                """ % (new, ", ".join(members), ", ".join(members))
+            self.check(b, a)
+
 
 class Test_input(FixerTestCase):
     fixer = "input"

Modified: python/branches/tlee-ast-optimize/Lib/test/test_bsddb.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_bsddb.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_bsddb.py	Mon May 26 13:42:06 2008
@@ -66,9 +66,6 @@
         self.assertSetEquals(d.iteritems(), f.iteritems())
 
     def test_iter_while_modifying_values(self):
-        if not hasattr(self.f, '__iter__'):
-            return
-
         di = iter(self.d)
         while 1:
             try:
@@ -80,20 +77,62 @@
         # it should behave the same as a dict.  modifying values
         # of existing keys should not break iteration.  (adding
         # or removing keys should)
+        loops_left = len(self.f)
         fi = iter(self.f)
         while 1:
             try:
                 key = fi.next()
                 self.f[key] = 'modified '+key
+                loops_left -= 1
             except StopIteration:
                 break
+        self.assertEqual(loops_left, 0)
 
         self.test_mapping_iteration_methods()
 
-    def test_iteritems_while_modifying_values(self):
-        if not hasattr(self.f, 'iteritems'):
-            return
+    def test_iter_abort_on_changed_size(self):
+        def DictIterAbort():
+            di = iter(self.d)
+            while 1:
+                try:
+                    di.next()
+                    self.d['newkey'] = 'SPAM'
+                except StopIteration:
+                    break
+        self.assertRaises(RuntimeError, DictIterAbort)
+
+        def DbIterAbort():
+            fi = iter(self.f)
+            while 1:
+                try:
+                    fi.next()
+                    self.f['newkey'] = 'SPAM'
+                except StopIteration:
+                    break
+        self.assertRaises(RuntimeError, DbIterAbort)
 
+    def test_iteritems_abort_on_changed_size(self):
+        def DictIteritemsAbort():
+            di = self.d.iteritems()
+            while 1:
+                try:
+                    di.next()
+                    self.d['newkey'] = 'SPAM'
+                except StopIteration:
+                    break
+        self.assertRaises(RuntimeError, DictIteritemsAbort)
+
+        def DbIteritemsAbort():
+            fi = self.f.iteritems()
+            while 1:
+                try:
+                    key, value = fi.next()
+                    del self.f[key]
+                except StopIteration:
+                    break
+        self.assertRaises(RuntimeError, DbIteritemsAbort)
+
+    def test_iteritems_while_modifying_values(self):
         di = self.d.iteritems()
         while 1:
             try:
@@ -105,13 +144,16 @@
         # it should behave the same as a dict.  modifying values
         # of existing keys should not break iteration.  (adding
         # or removing keys should)
+        loops_left = len(self.f)
         fi = self.f.iteritems()
         while 1:
             try:
                 k, v = fi.next()
                 self.f[k] = 'modified '+v
+                loops_left -= 1
             except StopIteration:
                 break
+        self.assertEqual(loops_left, 0)
 
         self.test_mapping_iteration_methods()
 
@@ -177,8 +219,8 @@
         # the database write and locking+threading support is enabled
         # the cursor's read lock will deadlock the write lock request..
 
-        # test the iterator interface (if present)
-        if hasattr(self.f, 'iteritems'):
+        # test the iterator interface
+        if True:
             if debug: print "D"
             i = self.f.iteritems()
             k,v = i.next()
@@ -213,10 +255,7 @@
         self.assert_(self.f[k], "be gone with ye deadlocks")
 
     def test_for_cursor_memleak(self):
-        if not hasattr(self.f, 'iteritems'):
-            return
-
-        # do the bsddb._DBWithCursor _iter_mixin internals leak cursors?
+        # do the bsddb._DBWithCursor iterator internals leak cursors?
         nc1 = len(self.f._cursor_refs)
         # create iterator
         i = self.f.iteritems()

Modified: python/branches/tlee-ast-optimize/Lib/test/test_gzip.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_gzip.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_gzip.py	Mon May 26 13:42:06 2008
@@ -24,14 +24,14 @@
 class TestGzip(unittest.TestCase):
     filename = test_support.TESTFN
 
-    def setUp (self):
+    def setUp(self):
         test_support.unlink(self.filename)
 
-    def tearDown (self):
+    def tearDown(self):
         test_support.unlink(self.filename)
 
 
-    def test_write (self):
+    def test_write(self):
         f = gzip.GzipFile(self.filename, 'wb') ; f.write(data1 * 50)
 
         # Try flush and fileno.
@@ -41,6 +41,9 @@
             os.fsync(f.fileno())
         f.close()
 
+        # Test multiple close() calls.
+        f.close()
+
     def test_read(self):
         self.test_write()
         # Try reading.

Modified: python/branches/tlee-ast-optimize/Misc/NEWS
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/NEWS	(original)
+++ python/branches/tlee-ast-optimize/Misc/NEWS	Mon May 26 13:42:06 2008
@@ -54,11 +54,19 @@
   bsddb.db.DBEnv.lock_get and other bsddb.db object constructors
   raised an exception.
 
+- Issue #2669: bsddb/__init__.py iteration no longer silently fails when
+  the database has changed size during iteration.  It now raises a
+  RuntimeError in the same manner as a dictionary.
+
 - Issue #2870: cmathmodule.c compile error.
 
 Library
 -------
 
+- Issue #2959: For consistency with other file-like objects, gzip's
+  GzipFile.close() can now be called multiple times without raising
+  an exception.
+
 - Issue #1390: Raise ValueError in toxml when an invalid comment would
   otherwise be produced.
 

Modified: python/branches/tlee-ast-optimize/Tools/msi/msi.py
==============================================================================
--- python/branches/tlee-ast-optimize/Tools/msi/msi.py	(original)
+++ python/branches/tlee-ast-optimize/Tools/msi/msi.py	Mon May 26 13:42:06 2008
@@ -382,6 +382,7 @@
              ])
 
     compileargs = r'-Wi "[TARGETDIR]Lib\compileall.py" -f -x bad_coding|badsyntax|site-packages|py3_ "[TARGETDIR]Lib"'
+    lib2to3args = r'-c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"'
     # See "CustomAction Table"
     add_data(db, "CustomAction", [
         # msidbCustomActionTypeFirstSequence + msidbCustomActionTypeTextData + msidbCustomActionTypeProperty
@@ -395,6 +396,7 @@
         # See "Custom Action Type 18"
         ("CompilePyc", 18, "python.exe", compileargs),
         ("CompilePyo", 18, "python.exe", "-O "+compileargs),
+        ("CompileGrammar", 18, "python.exe", lib2to3args),
         ])
 
     # UI Sequences, see "InstallUISequence Table", "Using a Sequence Table"
@@ -424,12 +426,14 @@
              ("UpdateEditIDLE", None, 1050),
              ("CompilePyc", "COMPILEALL", 6800),
              ("CompilePyo", "COMPILEALL", 6801),
+             ("CompileGrammar", "COMPILEALL", 6802),
             ])
     add_data(db, "AdminExecuteSequence",
             [("InitialTargetDir", 'TARGETDIR=""', 750),
              ("SetDLLDirToTarget", 'DLLDIR=""', 751),
              ("CompilePyc", "COMPILEALL", 6800),
              ("CompilePyo", "COMPILEALL", 6801),
+             ("CompileGrammar", "COMPILEALL", 6802),
             ])
 
     #####################################################################
@@ -840,6 +844,26 @@
         result.append((f, kw))
     return result
 
+def generate_license():
+    import shutil, glob
+    out = open("LICENSE.txt", "w")
+    shutil.copyfileobj(open(os.path.join(srcdir, "LICENSE")), out)
+    for dir, file in (("bzip2","LICENSE"),
+                      ("db", "LICENSE"),
+                      ("openssl", "LICENSE"),
+                      ("tcl", "license.terms"),
+                      ("tk", "license.terms")):
+        out.write("\nThis copy of Python includes a copy of %s, which is licensed under the following terms:\n\n" % dir)
+        dirs = glob.glob(srcdir+"/../"+dir+"-*")
+        if not dirs:
+            raise ValueError, "Could not find "+srcdir+"/../"+dir+"-*"
+        if len(dirs) > 2:
+            raise ValueError, "Multiple copies of "+dir
+        dir = dirs[0]
+        shutil.copyfileobj(open(os.path.join(dir, file)), out)
+    out.close()
+
+
 class PyDirectory(Directory):
     """By default, all components in the Python installer
     can run from source."""
@@ -860,7 +884,8 @@
         root.add_file("%s/w9xpopen.exe" % PCBUILD)
     root.add_file("README.txt", src="README")
     root.add_file("NEWS.txt", src="Misc/NEWS")
-    root.add_file("LICENSE.txt", src="LICENSE")
+    generate_license()
+    root.add_file("LICENSE.txt", src=os.path.abspath("LICENSE.txt"))
     root.start_component("python.exe", keyfile="python.exe")
     root.add_file("%s/python.exe" % PCBUILD)
     root.start_component("pythonw.exe", keyfile="pythonw.exe")
@@ -978,6 +1003,8 @@
         if dir=="setuptools":
             lib.add_file("cli.exe")
             lib.add_file("gui.exe")
+        if dir=="lib2to3":
+            lib.removefile("pickle", "*.pickle")
         if dir=="data" and parent.physical=="test" and parent.basedir.physical=="email":
             # This should contain all non-.svn files listed in subversion
             for f in os.listdir(lib.absolute):

Modified: python/branches/tlee-ast-optimize/Tools/msi/msilib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Tools/msi/msilib.py	(original)
+++ python/branches/tlee-ast-optimize/Tools/msi/msilib.py	Mon May 26 13:42:06 2008
@@ -571,6 +571,11 @@
                  [(self.component+"c", self.component, "*.pyc", self.logical, 2),
                   (self.component+"o", self.component, "*.pyo", self.logical, 2)])
 
+    def removefile(self, key, pattern):
+        "Add a RemoveFile entry"
+        add_data(self.db, "RemoveFile", [(self.component+key, self.component, pattern, self.logical, 2)])
+
+
 class Feature:
     def __init__(self, db, id, title, desc, display, level = 1,
                  parent=None, directory = None, attributes=0):


More information about the Python-checkins mailing list