`urlparse` ignores the `scheme` parameter when parsing a URL
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
urlparse ignores the scheme parameter when determining what part of a URL is the path and hostname.
from urllib.parse import urlparse
# This should be parsed as: http://www.example.com
parsed_url = urlparse('www.example.com', scheme='http')
print(parsed_url)
print(parsed_url.hostname)
ParseResult(scheme='http', netloc='', path='www.example.com', params='', query='', fragment='')
[empty string]
Should return:
ParseResult(scheme='http', netloc='', path='', params='', query='', fragment='')
www.example.com
Per the docs:
The
schemeargument gives the default addressing scheme, to be used only if the URL does not specify one.
CPython versions tested on:
3.8, 3.11
Operating systems tested on:
Windows
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported urlparse behavior on a supported CPython version and inspect the urllib.parse implementation and existing URL-parsing tests. Compare the handling of the scheme argument with the documented behavior and determine whether the requested hostname parsing is compatible with URL syntax. Done means the agreed behavior is covered by regression tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100