Skip to content

Commit 3c91409

Browse files
authored
Merge pull request #125 from phaustin/debug
force utf8 encoding in write_notebook_output
2 parents 6a0df85 + 752ef5c commit 3c91409

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

jupyter_sphinx/execute.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,12 @@ def write_notebook_output(notebook, output_dir, notebook_name):
256256
resources,
257257
os.path.join(output_dir, notebook_name + ".ipynb"),
258258
)
259-
# Write a script too.
259+
# Write a script too. Note that utf-8 is the de facto
260+
# standard encoding for notebooks.
260261
ext = notebook.metadata.language_info.file_extension
261262
contents = "\n\n".join(cell.source for cell in notebook.cells)
262-
with open(os.path.join(output_dir, notebook_name + ext), "w") as f:
263+
with open(os.path.join(output_dir, notebook_name + ext), "w",
264+
encoding = "utf8") as f:
263265
f.write(contents)
264266

265267

tests/test_execute.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ def doctree(
3333
):
3434
src_dir = tempfile.mkdtemp()
3535
source_trees.append(src_dir)
36-
with open(os.path.join(src_dir, "conf.py"), "w") as f:
36+
with open(os.path.join(src_dir, "conf.py"), "w", encoding = "utf8") as f:
3737
f.write("extensions = ['%s']" % entrypoint)
3838
if config is not None:
3939
f.write("\n" + config)
40-
with open(os.path.join(src_dir, "contents.rst"), "w") as f:
40+
with open(os.path.join(src_dir, "contents.rst"), "w", encoding = "utf8") as f:
4141
f.write(source)
4242
warnings = StringIO()
4343
app = SphinxTestApp(srcdir=path(src_dir), status=StringIO(), warning=warnings)

0 commit comments

Comments
 (0)