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

eric.araujo python-checkins at python.org
Mon May 2 13:39:31 CEST 2011


http://hg.python.org/cpython/rev/a13310c045b0
changeset:   69774:a13310c045b0
branch:      2.7
parent:      69773:d7cd797842c0
parent:      69772:b6af2c367549
user:        Éric Araujo <merwok at netwok.org>
date:        Mon May 02 13:36:18 2011 +0200
summary:
  Branch merge

files:
  Doc/documenting/markup.rst           |  25 +++++++++++++--
  Lib/anydbm.py                        |  24 ++++++++-------
  Lib/distutils/command/sdist.py       |  23 ++++++++------
  Lib/distutils/tests/test_register.py |   6 +-
  Lib/heapq.py                         |   6 +-
  Lib/sysconfig.py                     |   1 -
  6 files changed, 53 insertions(+), 32 deletions(-)


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
@@ -186,13 +186,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 directive should be nested in a class
+   directive, like in the example above.
 
 .. describe:: opcode
 
diff --git a/Lib/anydbm.py b/Lib/anydbm.py
--- a/Lib/anydbm.py
+++ b/Lib/anydbm.py
@@ -29,17 +29,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.
-
 """
 
 class error(Exception):
@@ -63,7 +54,18 @@
 
 error = tuple(_errors)
 
-def open(file, flag = 'r', mode = 0666):
+def open(file, flag='r', mode=0666):
+    """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.
+    """
+
     # guess the type of an existing database
     from whichdb import whichdb
     result=whichdb(file)
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
@@ -306,17 +306,20 @@
                             rstrip_ws=1,
                             collapse_join=1)
 
-        while 1:
-            line = template.readline()
-            if line is None:            # end of file
-                break
+        try:
+            while 1:
+                line = template.readline()
+                if line is None:            # end of file
+                    break
 
-            try:
-                self.filelist.process_template_line(line)
-            except DistutilsTemplateError, msg:
-                self.warn("%s, line %d: %s" % (template.filename,
-                                               template.current_line,
-                                               msg))
+                try:
+                    self.filelist.process_template_line(line)
+                except DistutilsTemplateError, 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
@@ -138,7 +138,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)
         self.assertEqual(req2['Content-length'], req1['Content-length'])
@@ -168,7 +168,7 @@
             del register_module.raw_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')
@@ -186,7 +186,7 @@
             del register_module.raw_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
@@ -178,7 +178,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,
@@ -368,7 +368,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):
@@ -406,7 +406,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/sysconfig.py b/Lib/sysconfig.py
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -639,7 +639,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

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


More information about the Python-checkins mailing list