diff options
author | Éric Araujo <merwok@netwok.org> | 2011-04-24 00:34:11 (GMT) |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2011-04-24 00:34:11 (GMT) |
commit | 5348b63a91e3517116fcef2a9e7019b640aa6c9f (patch) | |
tree | dd171bd8e060d227759ed3e1852dd646bc8cfd7b /Lib | |
parent | 7365accc20a5dff590fe3d7af7ec01b7173a59ea (diff) | |
parent | 2b9388a03325fa4452a8cb3b9df8a7fbb7302b87 (diff) | |
download | cpython-5348b63a91e3517116fcef2a9e7019b640aa6c9f.zip cpython-5348b63a91e3517116fcef2a9e7019b640aa6c9f.tar.gz cpython-5348b63a91e3517116fcef2a9e7019b640aa6c9f.tar.bz2 |
Branch merge
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/dbm/__init__.py | 22 | ||||
-rw-r--r-- | Lib/distutils/command/sdist.py | 25 | ||||
-rw-r--r-- | Lib/distutils/tests/test_register.py | 6 | ||||
-rw-r--r-- | Lib/heapq.py | 6 | ||||
-rw-r--r-- | Lib/json/__init__.py | 2 |
5 files changed, 33 insertions, 28 deletions
diff --git a/Lib/dbm/__init__.py b/Lib/dbm/__init__.py index 99c1637..57be17b 100644 --- a/Lib/dbm/__init__.py +++ b/Lib/dbm/__init__.py @@ -24,16 +24,8 @@ It has the following interface (key and data are strings): 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', 'error'] @@ -54,7 +46,17 @@ _modules = {} 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 index 1118060..fdbebd7 100644 --- a/Lib/distutils/command/sdist.py +++ b/Lib/distutils/command/sdist.py @@ -294,17 +294,20 @@ class sdist(Command): 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: - self.filelist.process_template_line(line) - except DistutilsTemplateError as msg: - self.warn("%s, line %d: %s" % (template.filename, - template.current_line, - msg)) + 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)) + 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 index c712f56..cb72a11 100644 --- a/Lib/distutils/tests/test_register.py +++ b/Lib/distutils/tests/test_register.py @@ -137,7 +137,7 @@ class RegisterTestCase(PyPIRCCommandTestCase): # 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 @@ class RegisterTestCase(PyPIRCCommandTestCase): 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 @@ class RegisterTestCase(PyPIRCCommandTestCase): 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 index b74818e..cc61294 100644 --- a/Lib/heapq.py +++ b/Lib/heapq.py @@ -172,7 +172,7 @@ def heappushpop(heap, item): 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, @@ -363,7 +363,7 @@ def nsmallest(n, iterable, key=None): 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): @@ -401,7 +401,7 @@ def nlargest(n, iterable, key=None): 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 index a746f9c..6d88931 100644 --- a/Lib/json/__init__.py +++ b/Lib/json/__init__.py @@ -31,7 +31,7 @@ Encoding basic Python object hierarchies:: 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:: |