Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
235dc9d7
Commit
235dc9d7
authored
Dec 15, 2018
by
Jason R. Coombs
Committed by
GitHub
Dec 15, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1501 from pypa/bugfix/1499-no-splituser
Remove use of splituser
parents
361013fe
42a792c3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
changelog.d/1499.change.rst
changelog.d/1499.change.rst
+1
-0
setuptools/package_index.py
setuptools/package_index.py
+10
-6
setuptools/tests/test_packageindex.py
setuptools/tests/test_packageindex.py
+16
-0
No files found.
changelog.d/1499.change.rst
0 → 100644
View file @
235dc9d7
``setuptools.package_index`` no longer relies on the deprecated ``urllib.parse.splituser`` per Python #27485.
setuptools/package_index.py
View file @
235dc9d7
...
@@ -850,13 +850,16 @@ class PackageIndex(Environment):
...
@@ -850,13 +850,16 @@ class PackageIndex(Environment):
def _download_svn(self, url, filename):
def _download_svn(self, url, filename):
warnings.warn("SVN download support is deprecated", UserWarning)
warnings.warn("SVN download support is deprecated", UserWarning)
def splituser(host):
user, delim, host = host.rpartition('@')
return user, host
url = url.split('#', 1)[0] # remove any fragment for svn's sake
url = url.split('#', 1)[0] # remove any fragment for svn's sake
creds = ''
creds = ''
if url.lower().startswith('svn:') and '@' in url:
if url.lower().startswith('svn:') and '@' in url:
scheme, netloc, path, p, q, f = urllib.parse.urlparse(url)
scheme, netloc, path, p, q, f = urllib.parse.urlparse(url)
if not netloc and path.startswith('//') and '/' in path[2:]:
if not netloc and path.startswith('//') and '/' in path[2:]:
netloc, path = path[2:].split('/', 1)
netloc, path = path[2:].split('/', 1)
auth, host =
urllib.parse.
splituser(netloc)
auth, host = splituser(netloc)
if auth:
if auth:
if ':' in auth:
if ':' in auth:
user, pw = auth.split(':', 1)
user, pw = auth.split(':', 1)
...
@@ -1047,15 +1050,16 @@ class PyPIConfig(configparser.RawConfigParser):
...
@@ -1047,15 +1050,16 @@ class PyPIConfig(configparser.RawConfigParser):
def open_with_auth(url, opener=urllib.request.urlopen):
def open_with_auth(url, opener=urllib.request.urlopen):
"""
Open
a
urllib2
request
,
handling
HTTP
authentication
"""
"""
Open
a
urllib2
request
,
handling
HTTP
authentication
"""
scheme, netloc, path, params, query, frag = urllib.parse.urlparse(url)
parsed = urllib.parse.urlparse(url)
scheme, netloc, path, params, query, frag = parsed
# Double scheme does not raise on Mac OS X as revealed by a
# Double scheme does not raise on Mac OS X as revealed by a
# failing test. We would expect "nonnumeric port". Refs #20.
# failing test. We would expect "nonnumeric port". Refs #20.
if netloc.endswith(':'):
if netloc.endswith(':'):
raise http_client.InvalidURL("nonnumeric port: ''")
raise http_client.InvalidURL("nonnumeric port: ''")
if scheme in ('http', 'https'):
if scheme in ('http', 'https')
and parsed.username
:
auth
, host = urllib.parse.splituser(netloc
)
auth
= ':'.join((parsed.username, parsed.password)
)
else:
else:
auth = None
auth = None
...
@@ -1068,7 +1072,7 @@ def open_with_auth(url, opener=urllib.request.urlopen):
...
@@ -1068,7 +1072,7 @@ def open_with_auth(url, opener=urllib.request.urlopen):
if auth:
if auth:
auth = "Basic " + _encode_auth(auth)
auth = "Basic " + _encode_auth(auth)
parts = scheme,
host
, path, params, query, frag
parts = scheme,
parsed.hostname
, path, params, query, frag
new_url = urllib.parse.urlunparse(parts)
new_url = urllib.parse.urlunparse(parts)
request = urllib.request.Request(new_url)
request = urllib.request.Request(new_url)
request.add_header("Authorization", auth)
request.add_header("Authorization", auth)
...
@@ -1082,7 +1086,7 @@ def open_with_auth(url, opener=urllib.request.urlopen):
...
@@ -1082,7 +1086,7 @@ def open_with_auth(url, opener=urllib.request.urlopen):
# Put authentication info back into request URL if same host,
# Put authentication info back into request URL if same host,
# so that links found on the page will work
# so that links found on the page will work
s2, h2, path2, param2, query2, frag2 = urllib.parse.urlparse(fp.url)
s2, h2, path2, param2, query2, frag2 = urllib.parse.urlparse(fp.url)
if s2 == scheme and h2 ==
host
:
if s2 == scheme and h2 ==
parsed.hostname
:
parts = s2, netloc, path2, param2, query2, frag2
parts = s2, netloc, path2, param2, query2, frag2
fp.url = urllib.parse.urlunparse(parts)
fp.url = urllib.parse.urlunparse(parts)
...
...
setuptools/tests/test_packageindex.py
View file @
235dc9d7
...
@@ -262,6 +262,22 @@ class TestPackageIndex:
...
@@ -262,6 +262,22 @@ class TestPackageIndex:
).
format
(
**
locals
())
).
format
(
**
locals
())
os_system_mock
.
assert_called_once_with
(
expected
)
os_system_mock
.
assert_called_once_with
(
expected
)
def
test_download_svn
(
self
,
tmpdir
):
url
=
'svn+https://svn.example/project#egg=foo'
index
=
setuptools
.
package_index
.
PackageIndex
()
with
mock
.
patch
(
"os.system"
)
as
os_system_mock
:
result
=
index
.
download
(
url
,
str
(
tmpdir
))
os_system_mock
.
assert_called
()
expected_dir
=
str
(
tmpdir
/
'project'
)
expected
=
(
'svn checkout -q '
'svn+https://svn.example/project {expected_dir}'
).
format
(
**
locals
())
os_system_mock
.
assert_called_once_with
(
expected
)
class
TestContentCheckers
:
class
TestContentCheckers
:
def
test_md5
(
self
):
def
test_md5
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment