[Python-checkins] r43490 - in python/trunk: Lib/mimetools.py Lib/test/test_urllib2.py Misc/NEWS
georg.brandl
python-checkins at python.org
Fri Mar 31 19:18:14 CEST 2006
Author: georg.brandl
Date: Fri Mar 31 19:18:06 2006
New Revision: 43490
Modified:
python/trunk/Lib/mimetools.py
python/trunk/Lib/test/test_urllib2.py
python/trunk/Misc/NEWS
Log:
Bug #1250170, Patch #1462230: handle socket.gethostname()
failures gracefully
Modified: python/trunk/Lib/mimetools.py
==============================================================================
--- python/trunk/Lib/mimetools.py (original)
+++ python/trunk/Lib/mimetools.py Fri Mar 31 19:18:06 2006
@@ -127,7 +127,10 @@
import time
if _prefix is None:
import socket
- hostid = socket.gethostbyname(socket.gethostname())
+ try:
+ hostid = socket.gethostbyname(socket.gethostname())
+ except socket.gaierror:
+ hostid = '127.0.0.1'
try:
uid = repr(os.getuid())
except AttributeError:
Modified: python/trunk/Lib/test/test_urllib2.py
==============================================================================
--- python/trunk/Lib/test/test_urllib2.py (original)
+++ python/trunk/Lib/test/test_urllib2.py Fri Mar 31 19:18:06 2006
@@ -349,13 +349,19 @@
TESTFN = test_support.TESTFN
urlpath = sanepathname2url(os.path.abspath(TESTFN))
towrite = "hello, world\n"
- for url in [
+ urls = [
"file://localhost%s" % urlpath,
"file://%s" % urlpath,
"file://%s%s" % (socket.gethostbyname('localhost'), urlpath),
- "file://%s%s" % (socket.gethostbyname(socket.gethostname()),
- urlpath),
- ]:
+ ]
+ try:
+ localaddr = socket.gethostbyname(socket.gethostname())
+ except socket.gaierror:
+ localaddr = ''
+ if localaddr:
+ urls.append("file://%s%s" % (localaddr, urlpath))
+
+ for url in urls:
f = open(TESTFN, "wb")
try:
try:
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Fri Mar 31 19:18:06 2006
@@ -485,6 +485,9 @@
Library
-------
+- Bug #1250170: mimetools now gracefully handles socket.gethostname()
+ failures gracefully.
+
- patch #1457316: "setup.py upload" now supports --identity to select the
key to be used for signing the uploaded code.
More information about the Python-checkins
mailing list