mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch 'stable' into 1.5-release
This commit is contained in:
commit
9fb398e475
2
CHANGES
2
CHANGES
@ -302,6 +302,8 @@ Bugs fixed
|
||||
* #1843: Fix documentation of descriptor classes that have a custom metaclass.
|
||||
Thanks to Erik Bray.
|
||||
* #3190: util.split_docinfo fails to parse multi-line field bodies
|
||||
* #3024, #3037: In Python3, application.Sphinx._log crushed when the log message cannot
|
||||
be encoded into console encoding.
|
||||
|
||||
Release 1.4.9 (released Nov 23, 2016)
|
||||
=====================================
|
||||
|
@ -358,7 +358,9 @@ class Sphinx(object):
|
||||
wfile.write(message)
|
||||
except UnicodeEncodeError:
|
||||
encoding = getattr(wfile, 'encoding', 'ascii') or 'ascii'
|
||||
wfile.write(message.encode(encoding, 'replace'))
|
||||
# wfile.write accept only str, not bytes.So, we encode and replace
|
||||
# non-encodable characters, then decode them.
|
||||
wfile.write(message.encode(encoding, 'replace').decode(encoding))
|
||||
if not nonl:
|
||||
wfile.write('\n')
|
||||
if hasattr(wfile, 'flush'):
|
||||
|
@ -8,6 +8,7 @@
|
||||
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
import codecs
|
||||
|
||||
from docutils import nodes
|
||||
|
||||
@ -49,21 +50,40 @@ def test_emit_with_nonascii_name_node(app, status, warning):
|
||||
|
||||
@with_app()
|
||||
def test_output(app, status, warning):
|
||||
# info with newline
|
||||
status.truncate(0) # __init__ writes to status
|
||||
status.seek(0)
|
||||
app.info("Nothing here...")
|
||||
assert status.getvalue() == "Nothing here...\n"
|
||||
# info without newline
|
||||
status.truncate(0)
|
||||
status.seek(0)
|
||||
app.info("Nothing here...", True)
|
||||
assert status.getvalue() == "Nothing here..."
|
||||
|
||||
# warning
|
||||
old_count = app._warncount
|
||||
app.warn("Bad news!")
|
||||
assert strip_escseq(warning.getvalue()) == "WARNING: Bad news!\n"
|
||||
assert app._warncount == old_count + 1
|
||||
|
||||
|
||||
@with_app()
|
||||
def test_output_with_unencodable_char(app, status, warning):
|
||||
|
||||
class StreamWriter(codecs.StreamWriter):
|
||||
def write(self, object):
|
||||
self.stream.write(object.encode('cp1252').decode('cp1252'))
|
||||
|
||||
app._status = StreamWriter(status)
|
||||
|
||||
# info with UnicodeEncodeError
|
||||
status.truncate(0)
|
||||
status.seek(0)
|
||||
app.info(u"unicode \u206d...")
|
||||
assert status.getvalue() == "unicode ?...\n"
|
||||
|
||||
|
||||
@with_app()
|
||||
def test_extensions(app, status, warning):
|
||||
app.setup_extension('shutil')
|
||||
|
Loading…
Reference in New Issue
Block a user