[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#682603: One more time for linkchecker



Hi Scott,

On Tue, Jul 24, 2012 at 06:10:51 -0400, Scott Kitterman wrote:

> +--- linkchecker-7.9.orig/linkcheck/url.py
> ++++ linkchecker-7.9/linkcheck/url.py
> +@@ -69,10 +69,13 @@ if sys.version_info[0] > 2 or sys.versio
> +                 scheme, url = url[:i].lower(), url[i+1:]
> +         if url[:2] == '//':
> +             netloc, url = urlparse._splitnetloc(url, 2)
> +-        if allow_fragments and scheme in urlparse.uses_fragment and '#' in url:
> +-            url, fragment = url.split('#', 1)
> +-        if scheme in urlparse.uses_query and '?' in url:
> +-            url, query = url.split('?', 1)
> ++        try:
> ++            if allow_fragments and scheme in urlparse.uses_fragment and '#' in url:
> ++                url, fragment = url.split('#', 1)
> ++            if scheme in urlparse.uses_query and '?' in url:
> ++                url, query = url.split('?', 1)
> ++        except AttributeError as errorstring:
> ++            print(errorstring)
> +         v = urlparse.SplitResult(scheme, netloc, url, query, fragment)
> +         urlparse._parse_cache[key] = v
> +         return v
> +@@ -344,7 +347,10 @@ def url_norm (url, encoding=None):
> +     is_idn = url_fix_host(urlparts)
> +     # query
> +     urlparts[3] = url_parse_query(urlparts[3], encoding=encoding)
> +-    is_hierarchical = urlparts[0] not in urlparse.non_hierarchical
> ++    try:
> ++        is_hierarchical = urlparts[0] not in urlparse.non_hierarchical
> ++    except AttributeError as errorstring:
> ++        print(errorstring)
> +     if is_hierarchical:
> +         # URL has a hierarchical path we should norm
> +         if not urlparts[2]:

So I may be missing something, but I don't see how this can possibly
work.  You catch the AttributeError, print it (why?), and then go on to
use variables that are set in the try block, which AFAICT is going to
explode with NameError?

Cheers,
Julien

Attachment: signature.asc
Description: Digital signature


Reply to: