Parcourir la source

liquid_tags: Open notebooks with utf-8 encoding

I discovered a problem with UTF-8 encoded notebooks. It throws a
DecodeError. We now use io.open() so we can define a encoding to open a
file. Works with ASCII and Unicode encoded notebooks.
Marvin Steadfast il y a 9 ans
Parent
commit
96df6e55f8
1 fichiers modifiés avec 2 ajouts et 1 suppressions
  1. 2 1
      liquid_tags/notebook.py

+ 2 - 1
liquid_tags/notebook.py

@@ -51,6 +51,7 @@ import warnings
 import re
 import os
 from functools import partial
+from io import open
 
 from .mdx_liquid_tags import LiquidTags
 
@@ -324,7 +325,7 @@ def notebook(preprocessor, tag, markup):
                             **subcell_kwarg)
 
     # read and parse the notebook
-    with open(nb_path) as f:
+    with open(nb_path, encoding='utf-8') as f:
         nb_text = f.read()
         if IPYTHON_VERSION < 3:
             nb_json = IPython.nbformat.current.reads_json(nb_text)