Skip to content

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

Merged
merged 4 commits into from
May 18, 2017
Merged

bpo-29976: urllib.parse clarify '' in scheme values. #984

merged 4 commits into from
May 18, 2017

Conversation

orsenthil
Copy link
Member

Issue for discussion: http://bugs.python.org/issue29976

@mention-bot
Copy link

@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.

@terryjreedy
Copy link
Member

Add 'bpo-29976: ' to the beginning of the title to invoke auto-linking of PR and status back to the issue.

@orsenthil orsenthil changed the title urllib.parse clarify '' in scheme values. bpo-29976: urllib.parse clarify '' in scheme values. Apr 7, 2017
@orsenthil
Copy link
Member Author

@terryjreedy - thanks for the note, I missed that one!


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
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Changed.

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.
Copy link
Member

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.

Copy link
Member Author

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.

# A classification of schemes.
# We use '' as the scheme value for default scheme in urlsplit and urlparse.

uses_relative = ['', 'ftp', 'http', 'gopher', 'nntp', 'imap',
Copy link
Member

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.

Copy link
Member Author

@orsenthil orsenthil Apr 9, 2017

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.

Copy link
Member

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”

Copy link
Member Author

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”

Copy link
Member Author

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.

@berkerpeksag
Copy link
Member

IMO the changes to __doc__ should go into another PR. Right now, diff is a bit noisy and it will clutter the purpose of git blame.

@orsenthil
Copy link
Member Author

Removed the unrelated docstring changes and I guess, this is good to go.

@orsenthil orsenthil merged commit 906f533 into python:master May 18, 2017
orsenthil added a commit that referenced this pull request May 21, 2017
orsenthil added a commit that referenced this pull request May 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants