Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-45084: Remove deprecated urllib.parse functions#28115

Closed
vstinner wants to merge 1 commit intopython:mainpython/cpython:mainfrom
vstinner:urlparse_removeCopy head branch name to clipboard
Closed

bpo-45084: Remove deprecated urllib.parse functions#28115
vstinner wants to merge 1 commit intopython:mainpython/cpython:mainfrom
vstinner:urlparse_removeCopy head branch name to clipboard

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Sep 1, 2021

Remove the following undocumented urllib.parse functions, deprecated
in Python 3.8:

  • splitattr()
  • splithost()
  • splitnport()
  • splitpasswd()
  • splitport()
  • splitquery()
  • splittag()
  • splittype()
  • splituser()
  • splitvalue()
  • to_bytes()

Use urlparse() or parse_qsl() instead.

https://bugs.python.org/issue45084

Remove the following undocumented urllib.parse functions, deprecated
in Python 3.8:

* splitattr()
* splithost()
* splitnport()
* splitpasswd()
* splitport()
* splitquery()
* splittag()
* splittype()
* splituser()
* splitvalue()
* to_bytes()

Use urlparse() or parse_qsl() instead.
@vstinner
Copy link
Member Author

vstinner commented Sep 2, 2021

test_venv.EnsurePipTest.test_with_pip() fails: pip uses distlib which imports urllib.parse.splituser().

(...)
  File "C:\Users\RUNNER~1\AppData\Local\Temp\tmpf3wz854y\pip-21.2.3-py3-none-any.whl\pip\_internal\commands\install.py", line 14, in <module>
  File "C:\Users\RUNNER~1\AppData\Local\Temp\tmpf3wz854y\pip-21.2.3-py3-none-any.whl\pip\_internal\cli\req_command.py", line 21, in <module>
  File "C:\Users\RUNNER~1\AppData\Local\Temp\tmpf3wz854y\pip-21.2.3-py3-none-any.whl\pip\_internal\index\package_finder.py", line 32, in <module>
  File "C:\Users\RUNNER~1\AppData\Local\Temp\tmpf3wz854y\pip-21.2.3-py3-none-any.whl\pip\_internal\req\__init__.py", line 8, in <module>
  File "C:\Users\RUNNER~1\AppData\Local\Temp\tmpf3wz854y\pip-21.2.3-py3-none-any.whl\pip\_internal\req\req_install.py", line 35, in <module>
  File "C:\Users\RUNNER~1\AppData\Local\Temp\tmpf3wz854y\pip-21.2.3-py3-none-any.whl\pip\_internal\operations\install\wheel.py", line 38, in <module>
  File "C:\Users\RUNNER~1\AppData\Local\Temp\tmpf3wz854y\pip-21.2.3-py3-none-any.whl\pip\_vendor\distlib\scripts.py", line 14, in <module>
  File "C:\Users\RUNNER~1\AppData\Local\Temp\tmpf3wz854y\pip-21.2.3-py3-none-any.whl\pip\_vendor\distlib\compat.py", line 71, in <module>
ImportError: cannot import name 'splituser' from 'urllib.parse' (D:\a\cpython\cpython\lib\urllib\parse.py)

@ambv
Copy link
Contributor

ambv commented Sep 2, 2021

I reported https://bitbucket.org/pypa/distlib/issues/152/distlib-is-incompatible-with-python-311 and let pip maintainers know as well.

@vstinner
Copy link
Member Author

vstinner commented Sep 2, 2021

supervisor 4.2.2:

from supervisor.compat import urllib
...
type, uri = urllib.splittype(serverurl)
host, path = urllib.splithost(uri)
host, port = urllib.splitport(host)

M2Crypto 0.38.0:

# six.moves doesn't support star imports
if six.PY3:
    from urllib.request import *  # noqa for other modules to import
    from urllib.parse import *  # noqa for other modules to import
    from urllib.error import *  # noqa for other modules to import
else:
    from urllib import *  # noqa

if isinstance(url, six.string_types):
    try:               # python 2
        # http://pydoc.org/2.5.1/urllib.html
        host, selector = splithost(url)
        if host:
            user_passwd, host = splituser(host)
            host = unquote(host)
        realhost = host
    except NameError:  # python 3 has no splithost
        ...
else:
    host, selector = url
    urltype, rest = splittype(selector)
    url = rest
    user_passwd = None
    if urltype.lower() != 'http':
        realhost = None
    else:
        try:               # python 2
            realhost, rest = splithost(rest)
            if realhost:
                user_passwd, realhost = splituser(realhost)
                if user_passwd:
                    selector = "%s://%s%s" % (urltype, realhost, rest)
        except NameError:  # python 3 has no splithost
            ...

@vstinner
Copy link
Member Author

This change broke too many Python projects. I prefer to abandon the deprecation idea for now.

@vstinner vstinner closed this Sep 21, 2021
@vstinner vstinner deleted the urlparse_remove branch September 21, 2021 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.