mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix two issues with non-ASCII characters being written to byte streams.
This commit is contained in:
parent
7debd67c23
commit
9e9766a41a
5
CHANGES
5
CHANGES
@ -1,6 +1,11 @@
|
||||
Release 0.5.1 (in development)
|
||||
==============================
|
||||
|
||||
* Don't crash on failing doctests with non-ASCII characters.
|
||||
|
||||
* Don't crash on writing status messages and warnings containing
|
||||
unencodable characters.
|
||||
|
||||
* Warn if a doctest extension block doesn't contain any code.
|
||||
|
||||
* Fix the handling of ``:param:`` and ``:type:`` doc fields when
|
||||
|
@ -144,13 +144,20 @@ class Sphinx(object):
|
||||
|
||||
def warn(self, message):
|
||||
self._warncount += 1
|
||||
self._warning.write('WARNING: %s\n' % message)
|
||||
try:
|
||||
self._warning.write('WARNING: %s\n' % message)
|
||||
except UnicodeEncodeError:
|
||||
encoding = getattr(self._warning, 'encoding', 'ascii')
|
||||
self._warning.write(('WARNING: %s\n' % message).encode(encoding, 'replace'))
|
||||
|
||||
def info(self, message='', nonl=False):
|
||||
if nonl:
|
||||
try:
|
||||
self._status.write(message)
|
||||
else:
|
||||
self._status.write(message + '\n')
|
||||
except UnicodeEncodeError:
|
||||
encoding = getattr(self._status, 'encoding', 'ascii')
|
||||
self._status.write(message.encode(encoding, 'replace'))
|
||||
if not nonl:
|
||||
self._status.write('\n')
|
||||
self._status.flush()
|
||||
|
||||
# general extensibility interface
|
||||
|
@ -13,6 +13,7 @@
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import codecs
|
||||
import StringIO
|
||||
from os import path
|
||||
# circumvent relative import
|
||||
@ -169,7 +170,8 @@ class DocTestBuilder(Builder):
|
||||
|
||||
date = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
self.outfile = file(path.join(self.outdir, 'output.txt'), 'w')
|
||||
self.outfile = codecs.open(path.join(self.outdir, 'output.txt'),
|
||||
'w', encoding='utf-8')
|
||||
self.outfile.write('''\
|
||||
Results of doctest builder run on %s
|
||||
==================================%s
|
||||
|
Loading…
Reference in New Issue
Block a user