File tree Expand file tree Collapse file tree 4 files changed +9
-3
lines changed Expand file tree Collapse file tree 4 files changed +9
-3
lines changed Original file line number Diff line number Diff line change
1
+ Fix remaining test failures in Python 3.14 by adjusting ``path_to_url `` and similar functions.
Original file line number Diff line number Diff line change 6
6
import os
7
7
import posixpath
8
8
import re
9
+ import sys
9
10
import urllib .parse
10
11
from collections .abc import Mapping
11
12
from dataclasses import dataclass
@@ -131,7 +132,11 @@ def _clean_file_url_path(part: str) -> str:
131
132
# should not be quoted. On Linux where drive letters do not
132
133
# exist, the colon should be quoted. We rely on urllib.request
133
134
# to do the right thing here.
134
- return urllib .request .pathname2url (urllib .request .url2pathname (part ))
135
+ ret = urllib .request .pathname2url (urllib .request .url2pathname (part ))
136
+ if sys .version_info >= (3 , 14 ):
137
+ # https://discuss.python.org/t/pathname2url-changes-in-python-3-14-breaking-pip-tests/97091
138
+ ret = ret .removeprefix ("//" )
139
+ return ret
135
140
136
141
137
142
# percent-encoded: /
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ def path_to_url(path: str) -> str:
12
12
quoted path parts.
13
13
"""
14
14
path = os .path .normpath (os .path .abspath (path ))
15
- url = urllib .parse .urljoin ("file:" , urllib .request .pathname2url (path ))
15
+ url = urllib .parse .urljoin ("file:// " , urllib .request .pathname2url (path ))
16
16
return url
17
17
18
18
Original file line number Diff line number Diff line change 11
11
def test_path_to_url_unix () -> None :
12
12
assert path_to_url ("/tmp/file" ) == "file:///tmp/file"
13
13
path = os .path .join (os .getcwd (), "file" )
14
- assert path_to_url ("file" ) == "file://" + urllib . request . pathname2url ( path )
14
+ assert path_to_url ("file" ) == "file://" + path
15
15
16
16
17
17
@pytest .mark .skipif ("sys.platform != 'win32'" )
You can’t perform that action at this time.
0 commit comments