From 0d7a2cac7266333b256c4d6fae5b81e6ba59d65f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Fri, 5 Jan 2018 20:05:17 +0100 Subject: [PATCH] Python3: fix decode_parts function --- linkcheck/url.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/linkcheck/url.py b/linkcheck/url.py index b30a23ec..2322cd76 100644 --- a/linkcheck/url.py +++ b/linkcheck/url.py @@ -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)