Skip to content

Commit

Permalink
Fix WASI
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Oct 20, 2024
1 parent ac43afd commit 38233cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Lib/pathlib/_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ def is_local_authority(authority):
authority = socket.gethostbyname(authority)
except socket.gaierror:
return False
except AttributeError:
return False # WASI doesn't have gethostbyname()

if _local_authorities is None:
try:
Expand Down
5 changes: 3 additions & 2 deletions Lib/test/test_pathlib/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1711,8 +1711,9 @@ def test_from_uri_posix(self):
self.assertEqual(P.from_uri('file:////foo/bar'), P('//foo/bar'))
self.assertEqual(P.from_uri('file://localhost/foo/bar'), P('/foo/bar'))
self.assertEqual(P.from_uri('file://localhost//foo/bar'), P('//foo/bar'))
self.assertEqual(P.from_uri('file://127.0.0.1/foo/bar'), P('/foo/bar'))
self.assertEqual(P.from_uri('file://127.0.0.1//foo/bar'), P('//foo/bar'))
if not is_wasi:
self.assertEqual(P.from_uri('file://127.0.0.1/foo/bar'), P('/foo/bar'))
self.assertEqual(P.from_uri('file://127.0.0.1//foo/bar'), P('//foo/bar'))
self.assertRaises(ValueError, P.from_uri, 'foo/bar')
self.assertRaises(ValueError, P.from_uri, '/foo/bar')
self.assertRaises(ValueError, P.from_uri, '//foo/bar')
Expand Down

0 comments on commit 38233cd

Please sign in to comment.