Merge pull request #272 from cjmayo/python3_22

{python3_22} Python3: fix decode_parts function
This commit is contained in:
Marius Gedminas 2019-09-09 18:37:49 +03:00 committed by GitHub
commit bb573e5eb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -350,11 +350,14 @@ def url_norm (url, encoding=None):
urlparts[2] = url_fix_wayback_query(urlparts[2]) # unencode colon in http[s]:// in wayback path
urlparts[4] = url_quote_part(urlparts[4], safechars="!$&'()*+,-./;=?@_~", encoding=encoding) # anchor
res = urlunsplit(urlparts)
if url.endswith('#') and not urlparts[4]:
if decode_for_unquote(url).endswith('#') and not urlparts[4]:
# re-append trailing empty fragment
res += '#'
if encode_unicode:
res = unicode(res)
try:
res = unicode(res)
except NameError:
pass
return (res, is_idn)