mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
FIX: Use codecs module
This commit is contained in:
parent
13438dc0d1
commit
01166199a0
@ -24,6 +24,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
import pydoc
|
import pydoc
|
||||||
import optparse
|
import optparse
|
||||||
|
import codecs
|
||||||
|
|
||||||
from jinja2 import FileSystemLoader, TemplateNotFound
|
from jinja2 import FileSystemLoader, TemplateNotFound
|
||||||
from jinja2.sandbox import SandboxedEnvironment
|
from jinja2.sandbox import SandboxedEnvironment
|
||||||
@ -217,14 +218,9 @@ def find_autosummary_in_files(filenames):
|
|||||||
"""
|
"""
|
||||||
documented = []
|
documented = []
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
with open(filename, 'rb') as f:
|
with codecs.open(filename, 'r', encoding='utf-8',
|
||||||
lines = f.read()
|
errors='ignore') as f:
|
||||||
try:
|
lines = f.read().splitlines()
|
||||||
# sometimes this fails (e.g., Windows Py3k w/utf-8 files)
|
|
||||||
lines = lines.decode()
|
|
||||||
except Exception:
|
|
||||||
lines = lines.decode('utf-8')
|
|
||||||
lines = lines.splitlines()
|
|
||||||
documented.extend(find_autosummary_in_lines(lines,
|
documented.extend(find_autosummary_in_lines(lines,
|
||||||
filename=filename))
|
filename=filename))
|
||||||
return documented
|
return documented
|
||||||
|
Loading…
Reference in New Issue
Block a user