Skip to content

Commit bb69e49

Browse files
committed
Fix WASI, docs
1 parent 79f5d05 commit bb69e49

3 files changed

Lines changed: 3 additions & 5 deletions

File tree

Lib/pathlib/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,10 +1274,9 @@ def from_uri(cls, uri):
12741274
from urllib.error import URLError
12751275
from urllib.request import url2pathname
12761276
try:
1277-
pathname = url2pathname(uri.removeprefix('file:'))
1277+
path = cls(url2pathname(uri.removeprefix('file:')))
12781278
except URLError as exc:
12791279
raise ValueError(exc.reason) from None
1280-
path = cls(pathname)
12811280
if not path.is_absolute():
12821281
raise ValueError(f"URI is not absolute: {uri!r}")
12831282
return path

Lib/urllib/request.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,6 @@ def parse_http_list(s):
14501450
return [part.strip() for part in res]
14511451

14521452
class FileHandler(BaseHandler):
1453-
# not entirely sure what the rules are here
14541453
def open_local_file(self, req):
14551454
import email.utils
14561455
import mimetypes
@@ -1480,7 +1479,7 @@ def _is_local_authority(authority):
14801479
return True
14811480
try:
14821481
address = socket.gethostbyname(authority)
1483-
except socket.gaierror:
1482+
except (socket.gaierror, AttributeError):
14841483
return False
14851484
if _local_addresses is None:
14861485
try:

Misc/NEWS.d/next/Library/2024-11-14-21-17-48.gh-issue-126838.Yr5vKF.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ Fix issue where :func:`urllib.request.url2pathname` mishandled file URLs with
22
authorities. If an authority is present and resolves to ``localhost``, it is
33
now discarded. If an authority is present but *doesn't* resolve to
44
``localhost``, then on Windows a UNC path is returned (as before), and on
5-
other platforms a :exc:`urllib.errors.URLError` is now raised.
5+
other platforms a :exc:`urllib.error.URLError` is now raised.

0 commit comments

Comments
 (0)