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

Skip to content

Commit 462dea4

Browse files
committed
Make sure rst files are read with UTF-8 encoding so as to avoid issues when locale is C (restricting the charset to ASCII)
1 parent 9b3c232 commit 462dea4

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ env:
3333
- PYTHON_VERSION=3.5 SPHINX_VERSION=1.5
3434
- PYTHON_VERSION=3.6 SPHINX_VERSION=1.6 CONDA_CHANNELS="conda-forge"
3535
- PYTHON_VERSION=3.6 SPHINX_VERSION=dev CONDA_DEPENDENCIES="setuptools cython pytest-cov"
36+
- PYTHON_VERSION=2.7 LOCALE=C
3637
- PYTHON_VERSION=3.6 LOCALE=C
3738
global:
3839
- LOCALE=default

sphinx_automodapi/automodsumm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class members that are inherited from a base class. This value can be
8686
import inspect
8787
import os
8888
import re
89+
import io
8990

9091
from sphinx.ext.autosummary import Autosummary
9192
from sphinx.ext.inheritance_diagram import InheritanceDiagram
@@ -305,7 +306,7 @@ def automodsumm_to_autosummary_lines(fn, app):
305306

306307
fullfn = os.path.join(app.builder.env.srcdir, fn)
307308

308-
with open(fullfn) as fr:
309+
with io.open(fullfn, encoding='utf8') as fr:
309310
# Note: we use __name__ here instead of just writing the module name in
310311
# case this extension is bundled into another package
311312
from . import automodapi

sphinx_automodapi/tests/test_cases.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# We store different cases in the cases sub-directory of the tests directory
55

66
import os
7+
import io
78
import sys
89
import glob
910
import shutil
@@ -109,6 +110,6 @@ def test_run_full_case(tmpdir, case_dir):
109110
path_relative = os.path.relpath(path_reference, output_dir)
110111
path_actual = os.path.join(docs_dir, path_relative)
111112
assert os.path.exists(path_actual)
112-
actual = open(path_actual).read()
113-
reference = open(path_reference).read()
113+
actual = io.open(path_actual, encoding='utf8').read()
114+
reference = io.open(path_reference, encoding='utf8').read()
114115
assert actual.strip() == reference.strip()

0 commit comments

Comments
 (0)