From d0fa844f9198cfdcd2998aa9b07ed454c6618fb0 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 17 Nov 2019 11:12:33 +0900 Subject: [PATCH] Fix #6806: linkcheck: Failure on parsing content --- CHANGES | 1 + sphinx/builders/linkcheck.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGES b/CHANGES index a1676d5d6..dc56e3cf9 100644 --- a/CHANGES +++ b/CHANGES @@ -48,6 +48,7 @@ Bugs fixed supported LaTeX engines: ¶, §, €, ∞, ±, →, ‣, –, superscript and subscript digits go through "as is" (as default OpenType font supports them) * #6704: linkcheck: Be defensive and handle newly defined HTTP error code +* #6806: linkcheck: Failure on parsing content * #6655: image URLs containing ``data:`` causes gettext builder crashed * #6584: i18n: Error when compiling message catalogs on Hindi * #6718: i18n: KeyError is raised if section title and table title are same diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py index 635d9df98..737079a02 100644 --- a/sphinx/builders/linkcheck.py +++ b/sphinx/builders/linkcheck.py @@ -59,6 +59,9 @@ def check_anchor(response: requests.requests.Response, anchor: str) -> bool: # Read file in chunks. If we find a matching anchor, we break # the loop early in hopes not to have to download the whole thing. for chunk in response.iter_content(chunk_size=4096, decode_unicode=True): + if isinstance(chunk, bytes): # requests failed to decode + chunk = chunk.decode() # manually try to decode it + parser.feed(chunk) if parser.found: break