@@ -269,7 +269,7 @@ def add_np_implementation(function, docstring):
269
269
270
270
271
271
def read_file (path ):
272
- with open (path ) as f :
272
+ with open (path , encoding = 'utf-8' ) as f :
273
273
return f .read ()
274
274
275
275
@@ -326,7 +326,7 @@ def get_module_docstring(filepath):
326
326
327
327
Also finds the line at which the docstring ends.
328
328
"""
329
- co = compile (open (filepath ).read (), filepath , 'exec' )
329
+ co = compile (open (filepath , encoding = 'utf-8' ).read (), filepath , 'exec' )
330
330
if co .co_consts and isinstance (co .co_consts [0 ], six .string_types ):
331
331
docstring = co .co_consts [0 ]
332
332
else :
@@ -347,8 +347,9 @@ def copy_examples(examples_dir, destination_dir):
347
347
module_path = os .path .join (examples_dir , file )
348
348
docstring , starting_line = get_module_docstring (module_path )
349
349
destination_file = os .path .join (destination_dir , file [:- 2 ] + 'md' )
350
- with open (destination_file , 'w+' ) as f_out , \
351
- open (os .path .join (examples_dir , file ), 'r+' ) as f_in :
350
+ with open (destination_file , 'w+' , encoding = 'utf-8' ) as f_out , \
351
+ open (os .path .join (examples_dir , file ),
352
+ 'r+' , encoding = 'utf-8' ) as f_in :
352
353
353
354
f_out .write (docstring + '\n \n ' )
354
355
@@ -391,7 +392,7 @@ def generate(sources_dir):
391
392
readme = read_file (os .path .join (str (keras_dir ), 'README.md' ))
392
393
index = read_file (os .path .join (template_dir , 'index.md' ))
393
394
index = index .replace ('{{autogenerated}}' , readme [readme .find ('##' ):])
394
- with open (os .path .join (sources_dir , 'index.md' ), 'w' ) as f :
395
+ with open (os .path .join (sources_dir , 'index.md' ), 'w' , encoding = 'utf-8' ) as f :
395
396
f .write (index )
396
397
397
398
print ('Generating docs for Keras %s.' % keras .__version__ )
@@ -457,7 +458,7 @@ def generate(sources_dir):
457
458
subdir = os .path .dirname (path )
458
459
if not os .path .exists (subdir ):
459
460
os .makedirs (subdir )
460
- with open (path , 'w' ) as f :
461
+ with open (path , 'w' , encoding = 'utf-8' ) as f :
461
462
f .write (mkdown )
462
463
463
464
shutil .copyfile (os .path .join (str (keras_dir ), 'CONTRIBUTING.md' ),
0 commit comments