mirror of https://github.com/python/cpython
failures gracefully
This commit is contained in:
parent
296aef8ebb
commit
dd2245f230
|
@ -127,7 +127,10 @@ def choose_boundary():
|
|||
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:
|
||||
|
|
|
@ -349,13 +349,19 @@ class HandlerTests(unittest.TestCase):
|
|||
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:
|
||||
|
|
Loading…
Reference in New Issue