8000 gh-82150: Make urllib.parse.urlsplit and urllib.parse.urlunsplit preserve the '?' and '#' delimiters of empty query and fragment components by geryogam · Pull Request #15642 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-82150: Make urllib.parse.urlsplit and urllib.parse.urlunsplit preserve the '?' and '#' delimiters of empty query and fragment components #15642

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

Closed
wants to merge 19 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update parse.py
  • Loading branch information
geryogam authored Sep 2, 2019
commit 4df550d8e482e29129ff9431dda65229a51d2aa9
11 changes: 8 additions & 3 deletions Lib/urllib/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def _encode_result(obj, encoding=_implicit_encoding,

def _decode_args(args, encoding=_implicit_encoding,
errors=_implicit_errors):
return tuple(x.decode(encoding, errors) if x else '' for x in args)
return tuple(x.decode(encoding, errors) if x else None if x is None else ''
for x in args)

def _coerce_args(*args):
# Invokes decode if necessary to create str args
Expand All @@ -129,15 +130,19 @@ class _ResultMixinStr(object):
__slots__ = ()

def encode(self, encoding='ascii', errors='strict'):
return self._encoded_counterpart(*(x.encode(encoding, errors) for x in self))
return self._encoded_counterpart(*(x.encode(encoding, errors)
if x is not None else None
for x in self))


class _ResultMixinBytes(object):
"""Standard approach to decoding parsed results from bytes to str"""
__slots__ = ()

def decode(self, encoding='ascii', errors='strict'):
return self._decoded_counterpart(*(x.decode(encoding, errors) for x in self))
return self._decoded_counterpart(*(x.decode(encoding, errors)
if x is not None else None
for x in self))


class _NetlocResultMixinBase(object):
Expand Down
0