diff options
author | Éric Araujo <merwok@netwok.org> | 2011-05-02 13:36:18 +0200 |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2011-05-02 13:36:18 +0200 |
commit | bbc7b2e42bbb335b53d863592ffed23a237dd243 (patch) | |
tree | 00d1793ca68e74bc530b2788e0a0cc0d9be80937 /Lib | |
parent | 6931238449f37bfc92fd2e500573487d707829ba (diff) | |
parent | ff6148556aa1a92482505012f5409b8ea1e96b71 (diff) | |
download | cpython-bbc7b2e42bbb335b53d863592ffed23a237dd243.tar.gz |
Branch merge
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/anydbm.py | 24 | ||||
-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/sysconfig.py | 1 |
5 files changed, 33 insertions, 29 deletions
diff --git a/Lib/anydbm.py b/Lib/anydbm.py index 8b01ef3ea4..ba7e90510a 100644 --- a/Lib/anydbm.py +++ b/Lib/anydbm.py @@ -29,17 +29,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. - """ class error(Exception): @@ -63,7 +54,18 @@ if not _defaultmod: 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 index 0c3b0b55bf..cf8982bd9d 100644 --- a/Lib/distutils/command/sdist.py +++ b/Lib/distutils/command/sdist.py @@ -306,17 +306,20 @@ class sdist(Command): rstrip_ws=1, collapse_join=1) - 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: + 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)) + 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 dd60f8c804..bf63487035 100644 --- a/Lib/distutils/tests/test_register.py +++ b/Lib/distutils/tests/test_register.py @@ -138,7 +138,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) self.assertEqual(req2['Content-length'], req1['Content-length']) @@ -168,7 +168,7 @@ class RegisterTestCase(PyPIRCCommandTestCase): 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 @@ class RegisterTestCase(PyPIRCCommandTestCase): 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 index 74f7310a2c..fcaca13442 100644 --- a/Lib/heapq.py +++ b/Lib/heapq.py @@ -178,7 +178,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, @@ -368,7 +368,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): @@ -406,7 +406,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/sysconfig.py b/Lib/sysconfig.py index 77402d8ab7..3146f30510 100644 --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -639,7 +639,6 @@ def get_platform(): 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 |