-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-29976: urllib.parse clarify '' in scheme values. #984
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
Conversation
@orsenthil, thanks for your PR! By analyzing the history of the files in this pull request, we identified @serhiy-storchaka, @ncoghlan and @Yhg1s to be potential reviewers. |
Add 'bpo-29976: ' to the beginning of the title to invoke auto-linking of PR and status back to the issue. |
@terryjreedy - thanks for the note, I missed that one! |
Lib/urllib/parse.py
Outdated
|
||
RFC 3986 is considered the current standard and any future changes to | ||
urlparse module should conform with it. The urlparse module is | ||
currently not entirely compliant with this RFC due to defacto | ||
currently not entirely compliant with this RFC due to de-facto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'de facto', without '-'. See for instance https://www.merriam-webster.com/dictionary/defacto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Changed.
Lib/urllib/parse.py
Outdated
uses_relative = ['ftp', 'http', 'gopher', 'nntp', 'imap', | ||
# A classification of schemes. | ||
# We have '' as scheme value to accommodate for the default value of scheme | ||
# arg in urlsplit and urlparse. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better, but without having used argparse yet, I think something like "Use ' ' as the scheme value to get the default scheme in urlsplit and urlparse." might be even better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I settled for this. # We use '' as the scheme value for default scheme in urlsplit and urlparse.
Lib/urllib/parse.py
Outdated
# A classification of schemes. | ||
# We use '' as the scheme value for default scheme in urlsplit and urlparse. | ||
|
||
uses_relative = ['', 'ftp', 'http', 'gopher', 'nntp', 'imap', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uses_relative only seems to affect “urljoin”, not “urlsplit” nor “urlparse”. The empty string means that you can join one relative URL onto another one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment applies to all three lists, uses_relative
, uses_netloc
and uses_params
.
All of them have '' (empty string) listed as supported scheme, because that is the default
def urlsplit(url, scheme='', allow_fragments=True):
and
def urlparse(url, scheme='', allow_fragments=True):
And the current comment is:
# A classification of schemes ('' means apply by default)
- I think, the existing comment is confusing, and thus, this change is to make it a bit clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I misunderstood the comment. I thought you were listing the functions that the lists affected. What about something like
The empty string classifies relative URLs with no scheme specified, being the default returned by “urlsplit” and “urlparse”
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me. I will write it as "default value".
The empty string classifies relative URLs with no scheme specified, being the default value returned by “urlsplit” and “urlparse”
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified the comment as per our discussion here.
IMO the changes to |
Removed the unrelated docstring changes and I guess, this is good to go. |
Issue for discussion: http://bugs.python.org/issue29976