Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5f28b7b

Browse files
committed
Merged revisions 70518,70521,70590,70594-70595 via svnmerge from
svn+ssh://[email protected]/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). ........
1 parent b476d59 commit 5f28b7b

4 files changed

Lines changed: 74 additions & 65 deletions

File tree

Lib/platform.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,10 +1254,10 @@ def processor():
12541254
def _sys_version(sys_version=None):
12551255

12561256
""" Returns a parsed version of Python's sys.version as tuple
1257-
(name, version, branch, revision, buildno, builddate, compiler)
1258-
referring to the Python implementation name, version, branch,
1259-
revision, build number, build date/time as string and the compiler
1260-
identification string.
1257+
(name, version, branch, revision, buildno, builddate, compiler)
1258+
referring to the Python implementation name, version, branch,
1259+
revision, build number, build date/time as string and the compiler
1260+
identification string.
12611261
12621262
Note that unlike the Python sys.version, the returned value
12631263
for the Python version will always include the patchlevel (it
@@ -1359,8 +1359,6 @@ def python_version():
13591359
will always include the patchlevel (it defaults to 0).
13601360
13611361
"""
1362-
if hasattr(sys, 'version_info'):
1363-
return '%i.%i.%i' % sys.version_info[:3]
13641362
return _sys_version()[1]
13651363

13661364
def python_version_tuple():
@@ -1372,8 +1370,6 @@ def python_version_tuple():
13721370
will always include the patchlevel (it defaults to 0).
13731371
13741372
"""
1375-
if hasattr(sys, 'version_info'):
1376-
return sys.version_info[:3]
13771373
return tuple(_sys_version()[1].split('.'))
13781374

13791375
def python_branch():

Lib/test/test_platform.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,48 @@ def get(python):
2525
finally:
2626
os.remove(link)
2727

28-
def test_machine(self):
29-
res = platform.machine()
30-
31-
def test_node(self):
32-
res = platform.node()
33-
3428
def test_platform(self):
3529
for aliased in (False, True):
3630
for terse in (False, True):
3731
res = platform.platform(aliased, terse)
3832

39-
def test_processor(self):
40-
res = platform.processor()
33+
def test_system(self):
34+
res = platform.system()
4135

42-
def test_python_build(self):
43-
res = platform.python_build()
36+
def test_node(self):
37+
res = platform.node()
4438

45-
def test_python_compiler(self):
46-
res = platform.python_compiler()
39+
def test_release(self):
40+
res = platform.release()
4741

4842
def test_version(self):
49-
res1 = platform.version()
50-
res2 = platform.version_tuple()
43+
res = platform.version()
44+
45+
def test_machine(self):
46+
res = platform.machine()
47+
48+
def test_processor(self):
49+
res = platform.processor()
50+
51+
def test_python_implementation(self):
52+
res = platform.python_implementation()
53+
54+
def test_python_version(self):
55+
res1 = platform.python_version()
56+
res2 = platform.python_version_tuple()
5157
self.assertEqual(res1, ".".join(res2))
5258

53-
def test_release(self):
54-
res = platform.release()
59+
def test_python_branch(self):
60+
res = platform.python_branch()
5561

56-
def test_system(self):
57-
res = platform.system()
62+
def test_python_revision(self):
63+
res = platform.python_revision()
5864

59-
def test_version(self):
60-
res = platform.version()
65+
def test_python_build(self):
66+
res = platform.python_build()
67+
68+
def test_python_compiler(self):
69+
res = platform.python_compiler()
6170

6271
def test_system_alias(self):
6372
res = platform.system_alias(

Lib/urllib/request.py

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,41 +1474,45 @@ def retrieve(self, url, filename=None, reporthook=None, data=None):
14741474
except IOError as msg:
14751475
pass
14761476
fp = self.open(url, data)
1477-
headers = fp.info()
1478-
if filename:
1479-
tfp = open(filename, 'wb')
1480-
else:
1481-
import tempfile
1482-
garbage, path = splittype(url)
1483-
garbage, path = splithost(path or "")
1484-
path, garbage = splitquery(path or "")
1485-
path, garbage = splitattr(path or "")
1486-
suffix = os.path.splitext(path)[1]
1487-
(fd, filename) = tempfile.mkstemp(suffix)
1488-
self.__tempfiles.append(filename)
1489-
tfp = os.fdopen(fd, 'wb')
1490-
result = filename, headers
1491-
if self.tempcache is not None:
1492-
self.tempcache[url] = result
1493-
bs = 1024*8
1494-
size = -1
1495-
read = 0
1496-
blocknum = 0
1497-
if reporthook:
1498-
if "content-length" in headers:
1499-
size = int(headers["Content-Length"])
1500-
reporthook(blocknum, bs, size)
1501-
while 1:
1502-
block = fp.read(bs)
1503-
if not block:
1504-
break
1505-
read += len(block)
1506-
tfp.write(block)
1507-
blocknum += 1
1508-
if reporthook:
1509-
reporthook(blocknum, bs, size)
1510-
fp.close()
1511-
tfp.close()
1477+
try:
1478+
headers = fp.info()
1479+
if filename:
1480+
tfp = open(filename, 'wb')
1481+
else:
1482+
import tempfile
1483+
garbage, path = splittype(url)
1484+
garbage, path = splithost(path or "")
1485+
path, garbage = splitquery(path or "")
1486+
path, garbage = splitattr(path or "")
1487+
suffix = os.path.splitext(path)[1]
1488+
(fd, filename) = tempfile.mkstemp(suffix)
1489+
self.__tempfiles.append(filename)
1490+
tfp = os.fdopen(fd, 'wb')
1491+
try:
1492+
result = filename, headers
1493+
if self.tempcache is not None:
1494+
self.tempcache[url] = result
1495+
bs = 1024*8
1496+
size = -1
1497+
read = 0
1498+
blocknum = 0
1499+
if reporthook:
1500+
if "content-length" in headers:
1501+
size = int(headers["Content-Length"])
1502+
reporthook(blocknum, bs, size)
1503+
while 1:
1504+
block = fp.read(bs)
1505+
if not block:
1506+
break
1507+
read += len(block)
1508+
tfp.write(block)
1509+
blocknum += 1
1510+
if reporthook:
1511+
reporthook(blocknum, bs, size)
1512+
finally:
1513+
tfp.close()
1514+
finally:
1515+
fp.close()
15121516
del fp
15131517
del tfp
15141518

Misc/python.man

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.TH PYTHON "1" "$Date$"
22

3-
./" To view this file while editing, run it through groff:
4-
./" groff -Tascii -man python.man | less
3+
.\" To view this file while editing, run it through groff:
4+
.\" groff -Tascii -man python.man | less
55

66
.SH NAME
77
python \- an interpreted, interactive, object-oriented programming language

0 commit comments

Comments
 (0)