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/.
|
* #1162, PR#139: singlehtml builder didn't copy images to _images/.
|
||||||
* #1173: Adjust setup.py dependencies because Jinja2 2.7 discontinued
|
* #1173: Adjust setup.py dependencies because Jinja2 2.7 discontinued
|
||||||
compatibility with Python < 3.3 and Python < 2.6. Thanks to Alexander Dupuy.
|
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"
|
* #1188: sphinx-quickstart raises UnicodeEncodeError if "Project version"
|
||||||
includes non-ASCII characters.
|
includes non-ASCII characters.
|
||||||
* #1189: "Title underline is too short" WARNING is given when using fullwidth
|
* #1189: "Title underline is too short" WARNING is given when using fullwidth
|
||||||
|
@ -323,10 +323,10 @@ def parselinenos(spec, total):
|
|||||||
def force_decode(string, encoding):
|
def force_decode(string, encoding):
|
||||||
"""Forcibly get a unicode string out of a bytestring."""
|
"""Forcibly get a unicode string out of a bytestring."""
|
||||||
if isinstance(string, bytes):
|
if isinstance(string, bytes):
|
||||||
|
try:
|
||||||
if encoding:
|
if encoding:
|
||||||
string = string.decode(encoding)
|
string = string.decode(encoding)
|
||||||
else:
|
else:
|
||||||
try:
|
|
||||||
# try decoding with utf-8, should only work for real UTF-8
|
# try decoding with utf-8, should only work for real UTF-8
|
||||||
string = string.decode('utf-8')
|
string = string.decode('utf-8')
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
|
Loading…
Reference in New Issue
Block a user