Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae2a8fc

Browse files
committed
Very old files (Python <= 2.2) are stored in latin-1 with a correct Content-Type.
1 parent ca1f1e5 commit ae2a8fc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

build_docs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,15 +980,15 @@ def proofread_canonicals(www_root: Path) -> None:
980980
"""<link rel="canonical" href="https://docs.python.org/([^"]*)" />"""
981981
)
982982
for file in www_root.glob("**/*.html"):
983-
html = file.read_text(encoding="UTF-8")
983+
html = file.read_text(encoding="UTF-8", errors="surrogateescape")
984984
canonical = canonical_re.search(html)
985985
if not canonical:
986986
continue
987987
target = canonical.group(1)
988988
if not (www_root / target).exists():
989989
logging.info("Removing broken canonical from %s to %s", file, target)
990990
html = html.replace(canonical.group(0), "")
991-
file.write_text(html, encoding="UTF-8")
991+
file.write_text(html, encoding="UTF-8", errors="surrogateescape")
992992

993993

994994
def main():

0 commit comments

Comments
 (0)