File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -816,14 +816,17 @@ def test_file(self):
816816 urls = [
817817 canonurl ,
818818 parsed ._replace (netloc = 'localhost' ).geturl (),
819- parsed ._replace (netloc = socket .gethostbyname ('localhost' )).geturl (),
820819 ]
821- try :
822- localaddr = socket .gethostbyname (socket .gethostname ())
823- except socket .gaierror :
824- localaddr = ''
825- if localaddr :
826- urls .append (parsed ._replace (netloc = localaddr ).geturl ())
820+ if os .name != 'nt' :
821+ # On POSIX the local hostname may appear in a local file URL.
822+ # On Windows this would be decoded as a UNC path.
823+ urls .append (parsed ._replace (netloc = socket .gethostbyname ('localhost' )).geturl ())
824+ try :
825+ localaddr = socket .gethostbyname (socket .gethostname ())
826+ except socket .gaierror :
827+ localaddr = ''
828+ if localaddr :
829+ urls .append (parsed ._replace (netloc = localaddr ).geturl ())
827830
828831 for url in urls :
829832 f = open (TESTFN , "wb" )
You can’t perform that action at this time.
0 commit comments