mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix: In python3 environment, make linkcheck cause "Can't convert 'bytes'
object to str implicitly" error when link target url has a hash part. Thanks to Jorge_C. Closes #1457
This commit is contained in:
parent
3ae8906447
commit
82a53382d5
3
CHANGES
3
CHANGES
@ -10,6 +10,9 @@ Bugs fixed
|
||||
* #1363: Fix i18n: missing python domain's cross-references with currentmodule
|
||||
directive or currentclass directive.
|
||||
* #1444: autosummary does not create the description from attributes docstring.
|
||||
* #1457: In python3 environment, make linkcheck cause "Can't convert 'bytes'
|
||||
object to str implicitly" error when link target url has a hash part.
|
||||
Thanks to Jorge_C.
|
||||
|
||||
Release 1.2.2 (released Mar 2, 2014)
|
||||
====================================
|
||||
|
@ -24,6 +24,7 @@ from docutils import nodes
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.util.console import purple, red, darkgreen, darkgray, \
|
||||
darkred, turquoise
|
||||
from sphinx.util.pycompat import TextIOWrapper
|
||||
|
||||
|
||||
class RedirectHandler(HTTPRedirectHandler):
|
||||
@ -142,7 +143,10 @@ class CheckExternalLinksBuilder(Builder):
|
||||
# Read the whole document and see if #hash exists
|
||||
req = Request(req_url)
|
||||
f = opener.open(req, **kwargs)
|
||||
found = check_anchor(f, unquote(hash))
|
||||
encoding = 'utf-8'
|
||||
if hasattr(f.headers, 'get_content_charset'):
|
||||
encoding = f.headers.get_content_charset() or encoding
|
||||
found = check_anchor(TextIOWrapper(f, encoding), unquote(hash))
|
||||
f.close()
|
||||
|
||||
if not found:
|
||||
|
Loading…
Reference in New Issue
Block a user