-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected urllib parse result #98022
Comments
Adding scheme does not seem to help: urlparse('1.2.3.4:80', 'http')
|
I might be horribly wrong, but from the example given -
I think it's treating the IP address of your string as the scheme because it's the first part of the URL string (before the colon). |
According to RFC3986 scheme should start with an alpha character. |
Quoting from the documentation of urlparse
To get your expected result, you need to prefix with
Since your input doesn't start with a scheme or |
Hello
Same if I specify the scheme in the function:
|
I think the issue boils down to this:
I get the impression that nowadays, most people do not know that according to RFC1738, a I will work on a patch for this |
On second thought and reading of the discussion on #38644, this is actually documented behaviour, as documented in the second paragraph of https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse. The only bug here then is as @planetA mentioned:
I can look into a fix for this - maybe raise an error if the parsed
This is technically documented behaviour too:
Since |
ping |
@arhadthedev Sorry I forgot about this. Taking a look again, the behaviour and changes I described above has already been fixed in this issue (#99418) and PR (#99421). We can close this issue now. |
Subject
I parse an IP address with port to get a url, but
ParseResult
does not look right.Environment
Describe your environment.
At least, paste here the output of:
Steps to Reproduce
Expected Behavior
Actual Behavior
I guess scheme should not be an IP address
This issue seems to be related: #38644
The text was updated successfully, but these errors were encountered: