mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Closes #1185: Don't crash when a Python module has a wrong or no encoding declared,
and non-ASCII characters are included.
This commit is contained in:
parent
8bd4860f4c
commit
ee2c8d01c2
2
CHANGES
2
CHANGES
@ -45,6 +45,8 @@ Bugs fixed
|
||||
* #1162, PR#139: singlehtml builder didn't copy images to _images/.
|
||||
* #1173: Adjust setup.py dependencies because Jinja2 2.7 discontinued
|
||||
compatibility with Python < 3.3 and Python < 2.6. Thanks to Alexander Dupuy.
|
||||
* #1185: Don't crash when a Python module has a wrong or no encoding declared,
|
||||
and non-ASCII characters are included.
|
||||
* #1188: sphinx-quickstart raises UnicodeEncodeError if "Project version"
|
||||
includes non-ASCII characters.
|
||||
* #1189: "Title underline is too short" WARNING is given when using fullwidth
|
||||
|
@ -323,15 +323,15 @@ def parselinenos(spec, total):
|
||||
def force_decode(string, encoding):
|
||||
"""Forcibly get a unicode string out of a bytestring."""
|
||||
if isinstance(string, bytes):
|
||||
if encoding:
|
||||
string = string.decode(encoding)
|
||||
else:
|
||||
try:
|
||||
try:
|
||||
if encoding:
|
||||
string = string.decode(encoding)
|
||||
else:
|
||||
# try decoding with utf-8, should only work for real UTF-8
|
||||
string = string.decode('utf-8')
|
||||
except UnicodeError:
|
||||
# last resort -- can't fail
|
||||
string = string.decode('latin1')
|
||||
except UnicodeError:
|
||||
# last resort -- can't fail
|
||||
string = string.decode('latin1')
|
||||
return string
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user