Commit b57a2203 authored by Georg Brandl's avatar Georg Brandl

Bug #1250170, Patch #1462230: handle socket.gethostname()

failures gracefully
parent fbfb36a4
...@@ -127,7 +127,10 @@ def choose_boundary(): ...@@ -127,7 +127,10 @@ def choose_boundary():
import time import time
if _prefix is None: if _prefix is None:
import socket import socket
try:
hostid = socket.gethostbyname(socket.gethostname()) hostid = socket.gethostbyname(socket.gethostname())
except socket.gaierror:
hostid = '127.0.0.1'
try: try:
uid = repr(os.getuid()) uid = repr(os.getuid())
except AttributeError: except AttributeError:
......
...@@ -349,13 +349,19 @@ class HandlerTests(unittest.TestCase): ...@@ -349,13 +349,19 @@ class HandlerTests(unittest.TestCase):
TESTFN = test_support.TESTFN TESTFN = test_support.TESTFN
urlpath = sanepathname2url(os.path.abspath(TESTFN)) urlpath = sanepathname2url(os.path.abspath(TESTFN))
towrite = "hello, world\n" towrite = "hello, world\n"
for url in [ urls = [
"file://localhost%s" % urlpath, "file://localhost%s" % urlpath,
"file://%s" % urlpath, "file://%s" % urlpath,
"file://%s%s" % (socket.gethostbyname('localhost'), 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") f = open(TESTFN, "wb")
try: try:
try: try:
......
...@@ -485,6 +485,9 @@ Extension Modules ...@@ -485,6 +485,9 @@ Extension Modules
Library Library
------- -------
- Bug #1250170: mimetools now gracefully handles socket.gethostname()
failures gracefully.
- patch #1457316: "setup.py upload" now supports --identity to select the - patch #1457316: "setup.py upload" now supports --identity to select the
key to be used for signing the uploaded code. key to be used for signing the uploaded code.
......
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