[Python-checkins] cpython (merge 3.2 -> 3.2): Branch merge

eric.araujo python-checkins at python.org
Wed Apr 27 16:39:19 CEST 2011


http://hg.python.org/cpython/rev/c981a9824122
changeset:   69628:c981a9824122
branch:      3.2
parent:      69590:b316019638df
parent:      69621:316a8f4d6617
user:        Éric Araujo <merwok at netwok.org>
date:        Wed Apr 27 16:25:27 2011 +0200
summary:
  Branch merge

files:
  Doc/c-api/intro.rst                  |   3 +-
  Doc/c-api/object.rst                 |   1 -
  Doc/distutils/examples.rst           |   2 +-
  Doc/documenting/markup.rst           |  25 +++++++++++++--
  Doc/library/collections.rst          |   4 +-
  Doc/library/dbm.rst                  |   4 +-
  Doc/library/json.rst                 |   2 +-
  Doc/library/runpy.rst                |   2 +-
  Lib/ast.py                           |   4 +-
  Lib/dbm/__init__.py                  |  22 +++++++------
  Lib/distutils/command/sdist.py       |  23 ++++++++------
  Lib/distutils/tests/test_register.py |   6 +-
  Lib/heapq.py                         |   6 +-
  Lib/json/__init__.py                 |   2 +-
  Lib/sysconfig.py                     |   1 -
  Lib/trace.py                         |   2 +-
  16 files changed, 64 insertions(+), 45 deletions(-)


diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst
--- a/Doc/c-api/intro.rst
+++ b/Doc/c-api/intro.rst
@@ -511,13 +511,12 @@
    module: builtins
    module: __main__
    module: sys
-   module: exceptions
    triple: module; search; path
    single: path (in module sys)
 
 The basic initialization function is :c:func:`Py_Initialize`. This initializes
 the table of loaded modules, and creates the fundamental modules
-:mod:`builtins`, :mod:`__main__`, :mod:`sys`, and :mod:`exceptions`.  It also
+:mod:`builtins`, :mod:`__main__`, and :mod:`sys`.  It also
 initializes the module search path (``sys.path``).
 
 .. index:: single: PySys_SetArgvEx()
diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst
--- a/Doc/c-api/object.rst
+++ b/Doc/c-api/object.rst
@@ -258,7 +258,6 @@
    This is the equivalent of the Python expression ``hash(o)``.
 
    .. versionchanged:: 3.2
-
       The return type is now Py_hash_t.  This is a signed integer the same size
       as Py_ssize_t.
 
diff --git a/Doc/distutils/examples.rst b/Doc/distutils/examples.rst
--- a/Doc/distutils/examples.rst
+++ b/Doc/distutils/examples.rst
@@ -279,7 +279,7 @@
 Where the long description is broken, ``check`` will be able to detect it
 by using the :mod:`docutils` parser::
 
-    $ pythontrunk setup.py check --restructuredtext
+    $ python setup.py check --restructuredtext
     running check
     warning: check: Title underline too short. (line 2)
     warning: check: Could not finish the parsing.
diff --git a/Doc/documenting/markup.rst b/Doc/documenting/markup.rst
--- a/Doc/documenting/markup.rst
+++ b/Doc/documenting/markup.rst
@@ -152,7 +152,7 @@
 
    Describes global data in a module, including both variables and values used
    as "defined constants."  Class and object attributes are not documented
-   using this environment.
+   using this directive.
 
 .. describe:: exception
 
@@ -165,7 +165,7 @@
    parameters, enclosing optional parameters in brackets.  Default values can be
    given if it enhances clarity.  For example::
 
-      .. function:: Timer.repeat([repeat=3[, number=1000000]])
+      .. function:: repeat([repeat=3[, number=1000000]])
 
    Object methods are not documented using this directive. Bound object methods
    placed in the module namespace as part of the public interface of the module
@@ -217,13 +217,30 @@
 
    Describes an object data attribute.  The description should include
    information about the type of the data to be expected and whether it may be
-   changed directly.
+   changed directly.  This directive should be nested in a class directive,
+   like in this example::
+
+      .. class:: Spam
+
+            Description of the class.
+
+            .. data:: ham
+
+               Description of the attribute.
+
+   If is also possible to document an attribute outside of a class directive,
+   for example if the documentation for different attributes and methods is
+   split in multiple sections.  The class name should then be included
+   explicitly::
+
+      .. data:: Spam.eggs
 
 .. describe:: method
 
    Describes an object method.  The parameters should not include the ``self``
    parameter.  The description should include similar information to that
-   described for ``function``.
+   described for ``function``.  This method should be nested in a class
+   method, like in the example above.
 
 .. describe:: decoratormethod
 
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -205,14 +205,14 @@
     * `Bag class <http://www.gnu.org/software/smalltalk/manual-base/html_node/Bag.html>`_
       in Smalltalk.
 
-    * Wikipedia entry for `Multisets <http://en.wikipedia.org/wiki/Multiset>`_\.
+    * Wikipedia entry for `Multisets <http://en.wikipedia.org/wiki/Multiset>`_.
 
     * `C++ multisets <http://www.demo2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm>`_
       tutorial with examples.
 
     * For mathematical operations on multisets and their use cases, see
       *Knuth, Donald. The Art of Computer Programming Volume II,
-      Section 4.6.3, Exercise 19*\.
+      Section 4.6.3, Exercise 19*.
 
     * To enumerate all distinct multisets of a given size over a given set of
       elements, see :func:`itertools.combinations_with_replacement`.
diff --git a/Doc/library/dbm.rst b/Doc/library/dbm.rst
--- a/Doc/library/dbm.rst
+++ b/Doc/library/dbm.rst
@@ -30,9 +30,9 @@
    name, such as ``'dbm.ndbm'`` or ``'dbm.gnu'``.
 
 
-.. function:: open(filename, flag='r', mode=0o666)
+.. function:: open(file, flag='r', mode=0o666)
 
-   Open the database file *filename* and return a corresponding object.
+   Open the database file *file* and return a corresponding object.
 
    If the database file already exists, the :func:`whichdb` function is used to
    determine its type and the appropriate module is used; if it does not exist,
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -34,7 +34,7 @@
 Compact encoding::
 
     >>> import json
-    >>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',',':'))
+    >>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',', ':'))
     '[1,2,3,{"4":5,"6":7}]'
 
 Pretty printing::
diff --git a/Doc/library/runpy.rst b/Doc/library/runpy.rst
--- a/Doc/library/runpy.rst
+++ b/Doc/library/runpy.rst
@@ -49,7 +49,7 @@
    loader does not make filename information available, this variable is set
    to :const:`None`.
 
-    ``__cached__`` will be set to ``None``.
+   ``__cached__`` will be set to ``None``.
 
    ``__loader__`` is set to the :pep:`302` module loader used to retrieve the
    code for the module (This loader may be a wrapper around the standard
diff --git a/Lib/ast.py b/Lib/ast.py
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -40,8 +40,8 @@
     """
     Safely evaluate an expression node or a string containing a Python
     expression.  The string or node provided may only consist of the following
-    Python literal structures: strings, numbers, tuples, lists, dicts, booleans,
-    and None.
+    Python literal structures: strings, bytes, numbers, tuples, lists, dicts,
+    sets, booleans, and None.
     """
     _safe_names = {'None': None, 'True': True, 'False': False}
     if isinstance(node_or_string, str):
diff --git a/Lib/dbm/__init__.py b/Lib/dbm/__init__.py
--- a/Lib/dbm/__init__.py
+++ b/Lib/dbm/__init__.py
@@ -23,16 +23,8 @@
         list = d.keys() # return a list of all existing keys (slow!)
 
 Future versions may change the order in which implementations are
-tested for existence, add interfaces to other dbm-like
+tested for existence, and add interfaces to other dbm-like
 implementations.
-
-The open function has an optional second argument.  This can be 'r',
-for read-only access, 'w', for read-write access of an existing
-database, 'c' for read-write access to a new or existing database, and
-'n' for read-write access to a new database.  The default is 'r'.
-
-Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it
-only if it doesn't exist; and 'n' always creates a new database.
 """
 
 __all__ = ['open', 'whichdb', 'error']
@@ -53,7 +45,17 @@
 error = (error, IOError)
 
 
-def open(file, flag = 'r', mode = 0o666):
+def open(file, flag='r', mode=0o666):
+    """Open or create database at path given by *file*.
+
+    Optional argument *flag* can be 'r' (default) for read-only access, 'w'
+    for read-write access of an existing database, 'c' for read-write access
+    to a new or existing database, and 'n' for read-write access to a new
+    database.
+
+    Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it
+    only if it doesn't exist; and 'n' always creates a new database.
+    """
     global _defaultmod
     if _defaultmod is None:
         for name in _names:
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -294,17 +294,20 @@
                             join_lines=1, lstrip_ws=1, rstrip_ws=1,
                             collapse_join=1)
 
-        while True:
-            line = template.readline()
-            if line is None:            # end of file
-                break
+        try:
+            while True:
+                line = template.readline()
+                if line is None:            # end of file
+                    break
 
-            try:
-                self.filelist.process_template_line(line)
-            except DistutilsTemplateError as msg:
-                self.warn("%s, line %d: %s" % (template.filename,
-                                               template.current_line,
-                                               msg))
+                try:
+                    self.filelist.process_template_line(line)
+                except DistutilsTemplateError as msg:
+                    self.warn("%s, line %d: %s" % (template.filename,
+                                                   template.current_line,
+                                                   msg))
+        finally:
+            template.close()
 
     def prune_file_list(self):
         """Prune off branches that might slip into the file list as created
diff --git a/Lib/distutils/tests/test_register.py b/Lib/distutils/tests/test_register.py
--- a/Lib/distutils/tests/test_register.py
+++ b/Lib/distutils/tests/test_register.py
@@ -137,7 +137,7 @@
 
         # let's see what the server received : we should
         # have 2 similar requests
-        self.assertTrue(self.conn.reqs, 2)
+        self.assertEqual(len(self.conn.reqs), 2)
         req1 = dict(self.conn.reqs[0].headers)
         req2 = dict(self.conn.reqs[1].headers)
 
@@ -169,7 +169,7 @@
             del register_module.input
 
         # we should have send a request
-        self.assertTrue(self.conn.reqs, 1)
+        self.assertEqual(len(self.conn.reqs), 1)
         req = self.conn.reqs[0]
         headers = dict(req.headers)
         self.assertEqual(headers['Content-length'], '608')
@@ -187,7 +187,7 @@
             del register_module.input
 
         # we should have send a request
-        self.assertTrue(self.conn.reqs, 1)
+        self.assertEqual(len(self.conn.reqs), 1)
         req = self.conn.reqs[0]
         headers = dict(req.headers)
         self.assertEqual(headers['Content-length'], '290')
diff --git a/Lib/heapq.py b/Lib/heapq.py
--- a/Lib/heapq.py
+++ b/Lib/heapq.py
@@ -170,7 +170,7 @@
     return item
 
 def heapify(x):
-    """Transform list into a heap, in-place, in O(len(heap)) time."""
+    """Transform list into a heap, in-place, in O(len(x)) time."""
     n = len(x)
     # Transform bottom-up.  The largest index there's any point to looking at
     # is the largest with a child index in-range, so must have 2*i + 1 < n,
@@ -360,7 +360,7 @@
             return [min(chain(head, it))]
         return [min(chain(head, it), key=key)]
 
-    # When n>=size, it's faster to use sort()
+    # When n>=size, it's faster to use sorted()
     try:
         size = len(iterable)
     except (TypeError, AttributeError):
@@ -398,7 +398,7 @@
             return [max(chain(head, it))]
         return [max(chain(head, it), key=key)]
 
-    # When n>=size, it's faster to use sort()
+    # When n>=size, it's faster to use sorted()
     try:
         size = len(iterable)
     except (TypeError, AttributeError):
diff --git a/Lib/json/__init__.py b/Lib/json/__init__.py
--- a/Lib/json/__init__.py
+++ b/Lib/json/__init__.py
@@ -31,7 +31,7 @@
 Compact encoding::
 
     >>> import json
-    >>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',',':'))
+    >>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',', ':'))
     '[1,2,3,{"4":5,"6":7}]'
 
 Pretty printing::
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -694,7 +694,6 @@
                     m = re.search(
                             r'<key>ProductUserVisibleVersion</key>\s*' +
                             r'<string>(.*?)</string>', f.read())
-                    f.close()
                     if m is not None:
                         macrelease = '.'.join(m.group(1).split('.')[:2])
                     # else: fall back to the default behaviour
diff --git a/Lib/trace.py b/Lib/trace.py
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -688,7 +688,7 @@
 
     for opt, val in opts:
         if opt == "--help":
-            usage(sys.stdout)
+            _usage(sys.stdout)
             sys.exit(0)
 
         if opt == "--version":

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list