|
42 | 42 | execfile |
43 | 43 | except NameError: |
44 | 44 | def execfile(filename, global_vars=None, local_vars=None): |
45 | | - with open(filename) as f: |
| 45 | + with open(filename, encoding='utf-8') as f: |
46 | 46 | code = compile(f.read(), filename, 'exec') |
47 | 47 | exec(code, global_vars, local_vars) |
48 | 48 |
|
@@ -426,7 +426,7 @@ def resolve(self, cobj, this_url): |
426 | 426 | def extract_docstring(filename, ignore_heading=False): |
427 | 427 | """ Extract a module-level docstring, if any |
428 | 428 | """ |
429 | | - lines = open(filename).readlines() |
| 429 | + lines = open(filename, encoding='utf-8').readlines() |
430 | 430 | start_row = 0 |
431 | 431 | if lines[0].startswith('#!'): |
432 | 432 | lines.pop(0) |
@@ -522,7 +522,7 @@ def generate_example_rst(app): |
522 | 522 | def extract_line_count(filename, target_dir): |
523 | 523 | # Extract the line count of a file |
524 | 524 | example_file = os.path.join(target_dir, filename) |
525 | | - lines = open(example_file).readlines() |
| 525 | + lines = open(example_file, encoding='utf-8').readlines() |
526 | 526 | start_row = 0 |
527 | 527 | if lines and lines[0].startswith('#!'): |
528 | 528 | lines.pop(0) |
@@ -955,7 +955,8 @@ def generate_file_rst(fname, target_dir, src_dir, root_dir, plot_gallery): |
955 | 955 | f.flush() |
956 | 956 |
|
957 | 957 | # save variables so we can later add links to the documentation |
958 | | - example_code_obj = identify_names(open(example_file).read()) |
| 958 | + example_code_obj = \ |
| 959 | + identify_names(open(example_file, encoding='utf-8').read()) |
959 | 960 | if example_code_obj: |
960 | 961 | codeobj_fname = example_file[:-3] + '_codeobj.pickle' |
961 | 962 | with open(codeobj_fname, 'wb') as fid: |
|
0 commit comments