[Python-checkins] r70630 - in python/branches/release30-maint: Lib/platform.py Lib/test/test_platform.py Lib/urllib/request.py Misc/python.man

benjamin.peterson python-checkins at python.org
Thu Mar 26 22:54:54 CET 2009


Author: benjamin.peterson
Date: Thu Mar 26 22:54:53 2009
New Revision: 70630

Log:
Merged revisions 70628 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r70628 | benjamin.peterson | 2009-03-26 16:49:58 -0500 (Thu, 26 Mar 2009) | 31 lines
  
  Merged revisions 70518,70521,70590,70594-70595 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r70518 | matthias.klose | 2009-03-22 08:08:22 -0500 (Sun, 22 Mar 2009) | 2 lines
    
    - Fix comment macro in python.man
  ........
    r70521 | benjamin.peterson | 2009-03-22 12:45:11 -0500 (Sun, 22 Mar 2009) | 1 line
    
    close the file even if an exception occurs #5536
  ........
    r70590 | skip.montanaro | 2009-03-24 19:52:11 -0500 (Tue, 24 Mar 2009) | 1 line
    
    clarify the type of data returned
  ........
    r70594 | marc-andre.lemburg | 2009-03-25 14:44:58 -0500 (Wed, 25 Mar 2009) | 9 lines
    
    Remove the sys.version_info shortcut, since they cause the APIs
    to return different information than the _sys_version() output
    used in previous Python versions.
    
    This also fixes issue5561: platform.python_version_tuple returns tuple of ints, should be strings
    
    Added more tests for the various platform functions.
  ........
    r70595 | marc-andre.lemburg | 2009-03-25 14:45:33 -0500 (Wed, 25 Mar 2009) | 3 lines
    
    News item for the platform.py fix (r70594).
  ........
................


Modified:
   python/branches/release30-maint/   (props changed)
   python/branches/release30-maint/Lib/platform.py
   python/branches/release30-maint/Lib/test/test_platform.py
   python/branches/release30-maint/Lib/urllib/request.py
   python/branches/release30-maint/Misc/python.man

Modified: python/branches/release30-maint/Lib/platform.py
==============================================================================
--- python/branches/release30-maint/Lib/platform.py	(original)
+++ python/branches/release30-maint/Lib/platform.py	Thu Mar 26 22:54:53 2009
@@ -1254,10 +1254,10 @@
 def _sys_version(sys_version=None):
 
     """ Returns a parsed version of Python's sys.version as tuple
-       (name, version, branch, revision, buildno, builddate, compiler)
-       referring to the Python implementation name, version, branch,
-       revision, build number, build date/time as string and the compiler
-       identification string.
+        (name, version, branch, revision, buildno, builddate, compiler)
+        referring to the Python implementation name, version, branch,
+        revision, build number, build date/time as string and the compiler
+        identification string.
 
         Note that unlike the Python sys.version, the returned value
         for the Python version will always include the patchlevel (it
@@ -1359,8 +1359,6 @@
         will always include the patchlevel (it defaults to 0).
 
     """
-    if hasattr(sys, 'version_info'):
-        return '%i.%i.%i' % sys.version_info[:3]
     return _sys_version()[1]
 
 def python_version_tuple():
@@ -1372,8 +1370,6 @@
         will always include the patchlevel (it defaults to 0).
 
     """
-    if hasattr(sys, 'version_info'):
-        return sys.version_info[:3]
     return tuple(_sys_version()[1].split('.'))
 
 def python_branch():

Modified: python/branches/release30-maint/Lib/test/test_platform.py
==============================================================================
--- python/branches/release30-maint/Lib/test/test_platform.py	(original)
+++ python/branches/release30-maint/Lib/test/test_platform.py	Thu Mar 26 22:54:53 2009
@@ -25,39 +25,48 @@
             finally:
                 os.remove(link)
 
-    def test_machine(self):
-        res = platform.machine()
-
-    def test_node(self):
-        res = platform.node()
-
     def test_platform(self):
         for aliased in (False, True):
             for terse in (False, True):
                 res = platform.platform(aliased, terse)
 
-    def test_processor(self):
-        res = platform.processor()
+    def test_system(self):
+        res = platform.system()
 
-    def test_python_build(self):
-        res = platform.python_build()
+    def test_node(self):
+        res = platform.node()
 
-    def test_python_compiler(self):
-        res = platform.python_compiler()
+    def test_release(self):
+        res = platform.release()
 
     def test_version(self):
-        res1 = platform.version()
-        res2 = platform.version_tuple()
+        res = platform.version()
+
+    def test_machine(self):
+        res = platform.machine()
+
+    def test_processor(self):
+        res = platform.processor()
+
+    def test_python_implementation(self):
+        res = platform.python_implementation()
+
+    def test_python_version(self):
+        res1 = platform.python_version()
+        res2 = platform.python_version_tuple()
         self.assertEqual(res1, ".".join(res2))
 
-    def test_release(self):
-        res = platform.release()
+    def test_python_branch(self):
+        res = platform.python_branch()
 
-    def test_system(self):
-        res = platform.system()
+    def test_python_revision(self):
+        res = platform.python_revision()
 
-    def test_version(self):
-        res = platform.version()
+    def test_python_build(self):
+        res = platform.python_build()
+
+    def test_python_compiler(self):
+        res = platform.python_compiler()
 
     def test_system_alias(self):
         res = platform.system_alias(

Modified: python/branches/release30-maint/Lib/urllib/request.py
==============================================================================
--- python/branches/release30-maint/Lib/urllib/request.py	(original)
+++ python/branches/release30-maint/Lib/urllib/request.py	Thu Mar 26 22:54:53 2009
@@ -1474,41 +1474,45 @@
             except IOError as msg:
                 pass
         fp = self.open(url, data)
-        headers = fp.info()
-        if filename:
-            tfp = open(filename, 'wb')
-        else:
-            import tempfile
-            garbage, path = splittype(url)
-            garbage, path = splithost(path or "")
-            path, garbage = splitquery(path or "")
-            path, garbage = splitattr(path or "")
-            suffix = os.path.splitext(path)[1]
-            (fd, filename) = tempfile.mkstemp(suffix)
-            self.__tempfiles.append(filename)
-            tfp = os.fdopen(fd, 'wb')
-        result = filename, headers
-        if self.tempcache is not None:
-            self.tempcache[url] = result
-        bs = 1024*8
-        size = -1
-        read = 0
-        blocknum = 0
-        if reporthook:
-            if "content-length" in headers:
-                size = int(headers["Content-Length"])
-            reporthook(blocknum, bs, size)
-        while 1:
-            block = fp.read(bs)
-            if not block:
-                break
-            read += len(block)
-            tfp.write(block)
-            blocknum += 1
-            if reporthook:
-                reporthook(blocknum, bs, size)
-        fp.close()
-        tfp.close()
+        try:
+            headers = fp.info()
+            if filename:
+                tfp = open(filename, 'wb')
+            else:
+                import tempfile
+                garbage, path = splittype(url)
+                garbage, path = splithost(path or "")
+                path, garbage = splitquery(path or "")
+                path, garbage = splitattr(path or "")
+                suffix = os.path.splitext(path)[1]
+                (fd, filename) = tempfile.mkstemp(suffix)
+                self.__tempfiles.append(filename)
+                tfp = os.fdopen(fd, 'wb')
+            try:
+                result = filename, headers
+                if self.tempcache is not None:
+                    self.tempcache[url] = result
+                bs = 1024*8
+                size = -1
+                read = 0
+                blocknum = 0
+                if reporthook:
+                    if "content-length" in headers:
+                        size = int(headers["Content-Length"])
+                    reporthook(blocknum, bs, size)
+                while 1:
+                    block = fp.read(bs)
+                    if not block:
+                        break
+                    read += len(block)
+                    tfp.write(block)
+                    blocknum += 1
+                    if reporthook:
+                        reporthook(blocknum, bs, size)
+            finally:
+                tfp.close()
+        finally:
+            fp.close()
         del fp
         del tfp
 

Modified: python/branches/release30-maint/Misc/python.man
==============================================================================
--- python/branches/release30-maint/Misc/python.man	(original)
+++ python/branches/release30-maint/Misc/python.man	Thu Mar 26 22:54:53 2009
@@ -1,7 +1,7 @@
 .TH PYTHON "1" "$Date$"
 
-./" To view this file while editing, run it through groff:
-./"   groff -Tascii -man python.man | less
+.\" To view this file while editing, run it through groff:
+.\"   groff -Tascii -man python.man | less
 
 .SH NAME
 python \- an interpreted, interactive, object-oriented programming language


More information about the Python-checkins mailing list