Commit 5f28b7b7 authored by Benjamin Peterson's avatar Benjamin Peterson

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).
........
parent b476d597
...@@ -1359,8 +1359,6 @@ def python_version(): ...@@ -1359,8 +1359,6 @@ def python_version():
will always include the patchlevel (it defaults to 0). 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] return _sys_version()[1]
def python_version_tuple(): def python_version_tuple():
...@@ -1372,8 +1370,6 @@ def python_version_tuple(): ...@@ -1372,8 +1370,6 @@ def python_version_tuple():
will always include the patchlevel (it defaults to 0). 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('.')) return tuple(_sys_version()[1].split('.'))
def python_branch(): def python_branch():
......
...@@ -25,39 +25,48 @@ class PlatformTest(unittest.TestCase): ...@@ -25,39 +25,48 @@ class PlatformTest(unittest.TestCase):
finally: finally:
os.remove(link) os.remove(link)
def test_machine(self):
res = platform.machine()
def test_node(self):
res = platform.node()
def test_platform(self): def test_platform(self):
for aliased in (False, True): for aliased in (False, True):
for terse in (False, True): for terse in (False, True):
res = platform.platform(aliased, terse) res = platform.platform(aliased, terse)
def test_processor(self): def test_system(self):
res = platform.processor() res = platform.system()
def test_python_build(self): def test_node(self):
res = platform.python_build() res = platform.node()
def test_python_compiler(self): def test_release(self):
res = platform.python_compiler() res = platform.release()
def test_version(self): def test_version(self):
res1 = platform.version() res = platform.version()
res2 = platform.version_tuple()
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)) self.assertEqual(res1, ".".join(res2))
def test_release(self): def test_python_branch(self):
res = platform.release() res = platform.python_branch()
def test_system(self): def test_python_revision(self):
res = platform.system() res = platform.python_revision()
def test_version(self): def test_python_build(self):
res = platform.version() res = platform.python_build()
def test_python_compiler(self):
res = platform.python_compiler()
def test_system_alias(self): def test_system_alias(self):
res = platform.system_alias( res = platform.system_alias(
......
...@@ -1474,6 +1474,7 @@ class URLopener: ...@@ -1474,6 +1474,7 @@ class URLopener:
except IOError as msg: except IOError as msg:
pass pass
fp = self.open(url, data) fp = self.open(url, data)
try:
headers = fp.info() headers = fp.info()
if filename: if filename:
tfp = open(filename, 'wb') tfp = open(filename, 'wb')
...@@ -1487,6 +1488,7 @@ class URLopener: ...@@ -1487,6 +1488,7 @@ class URLopener:
(fd, filename) = tempfile.mkstemp(suffix) (fd, filename) = tempfile.mkstemp(suffix)
self.__tempfiles.append(filename) self.__tempfiles.append(filename)
tfp = os.fdopen(fd, 'wb') tfp = os.fdopen(fd, 'wb')
try:
result = filename, headers result = filename, headers
if self.tempcache is not None: if self.tempcache is not None:
self.tempcache[url] = result self.tempcache[url] = result
...@@ -1507,8 +1509,10 @@ class URLopener: ...@@ -1507,8 +1509,10 @@ class URLopener:
blocknum += 1 blocknum += 1
if reporthook: if reporthook:
reporthook(blocknum, bs, size) reporthook(blocknum, bs, size)
fp.close() finally:
tfp.close() tfp.close()
finally:
fp.close()
del fp del fp
del tfp del tfp
......
.TH PYTHON "1" "$Date$" .TH PYTHON "1" "$Date$"
./" To view this file while editing, run it through groff: .\" To view this file while editing, run it through groff:
./" groff -Tascii -man python.man | less .\" groff -Tascii -man python.man | less
.SH NAME .SH NAME
python \- an interpreted, interactive, object-oriented programming language python \- an interpreted, interactive, object-oriented programming language
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment