Fix #2684: sphinx.ext.intersphinx crashes with six-1.4.1

This commit is contained in:
Takeshi KOMIYA 2016-06-18 10:25:43 +09:00
parent 65dddfcd69
commit 7586297d6d
2 changed files with 7 additions and 5 deletions

View File

@ -12,6 +12,7 @@ Bugs fixed
* #2676: (latex) Error with verbatim text in captions since Sphinx 1.4.4 * #2676: (latex) Error with verbatim text in captions since Sphinx 1.4.4
* #2629: memoir class crashes LaTeX. Fixed ``by latex_keep_old_macro_names=False`` (ref 2675) * #2629: memoir class crashes LaTeX. Fixed ``by latex_keep_old_macro_names=False`` (ref 2675)
* #2684: `sphinx.ext.intersphinx` crashes with six-1.4.1
Release 1.4.4 (released Jun 12, 2016) Release 1.4.4 (released Jun 12, 2016)

View File

@ -34,7 +34,8 @@ from os import path
import re import re
from six import iteritems, string_types from six import iteritems, string_types
from six.moves.urllib import parse, request from six.moves.urllib import request
from six.moves.urllib.parse import urlsplit, urlunsplit
from docutils import nodes from docutils import nodes
from docutils.utils import relative_path from docutils.utils import relative_path
@ -145,7 +146,7 @@ def _strip_basic_auth(url):
:rtype: ``tuple`` :rtype: ``tuple``
""" """
url_parts = parse.urlsplit(url) url_parts = urlsplit(url)
username = url_parts.username username = url_parts.username
password = url_parts.password password = url_parts.password
frags = list(url_parts) frags = list(url_parts)
@ -154,7 +155,7 @@ def _strip_basic_auth(url):
frags[1] = "%s:%s" % (url_parts.hostname, url_parts.port) frags[1] = "%s:%s" % (url_parts.hostname, url_parts.port)
else: else:
frags[1] = url_parts.hostname frags[1] = url_parts.hostname
url = parse.urlunsplit(frags) url = urlunsplit(frags)
return (url, username, password) return (url, username, password)
@ -208,12 +209,12 @@ def _get_safe_url(url):
url, username, _ = _strip_basic_auth(url) url, username, _ = _strip_basic_auth(url)
if username is not None: if username is not None:
# case: url contained basic auth creds; obscure password # case: url contained basic auth creds; obscure password
url_parts = parse.urlsplit(url) url_parts = urlsplit(url)
safe_netloc = '{0}@{1}'.format(username, url_parts.hostname) safe_netloc = '{0}@{1}'.format(username, url_parts.hostname)
# replace original netloc w/ obscured version # replace original netloc w/ obscured version
frags = list(url_parts) frags = list(url_parts)
frags[1] = safe_netloc frags[1] = safe_netloc
safe_url = parse.urlunsplit(frags) safe_url = urlunsplit(frags)
return safe_url return safe_url