|
1 | 1 | from __future__ import absolute_import, division, print_function, unicode_literals
|
2 | 2 | from .. import source, lexer
|
3 |
| -import os |
| 3 | +import os, codecs |
4 | 4 |
|
5 | 5 | _buf = None
|
6 |
| -with open(os.path.join(os.path.dirname(__file__), '..', 'parser.py')) as f: |
| 6 | +with codecs.open(os.path.join(os.path.dirname(__file__), '..', 'parser.py'), |
| 7 | + encoding='utf-8') as f: |
7 | 8 | _buf = source.Buffer(f.read(), f.name)
|
8 | 9 |
|
9 | 10 | # Inject the grammar with locations of rules, because Python's
|
@@ -54,7 +55,8 @@ def instrument():
|
54 | 55 | if data is not None:
|
55 | 56 | rewriter.insert_before(token.loc, data)
|
56 | 57 |
|
57 |
| - with open(os.path.join(os.path.dirname(__file__), 'parser.py'), 'w') as f: |
| 58 | + with codecs.open(os.path.join(os.path.dirname(__file__), 'parser.py'), 'w', |
| 59 | + encoding='utf-8') as f: |
58 | 60 | f.write(rewriter.rewrite().source)
|
59 | 61 |
|
60 | 62 | # Produce an HTML report for test coverage of parser rules.
|
@@ -89,8 +91,8 @@ def report(parser, name='parser'):
|
89 | 91 | lambda x: r"<span id='{0}' class='line'>{1}</span>".format(*x),
|
90 | 92 | enumerate(content.split("\n"), 1)))
|
91 | 93 |
|
92 |
| - with open(os.path.join(os.path.dirname(__file__), '..', '..', |
93 |
| - 'doc', 'coverage', name + '.html'), 'w') as f: |
| 94 | + with codecs.open(os.path.join(os.path.dirname(__file__), '..', '..', |
| 95 | + 'doc', 'coverage', name + '.html'), 'w', encoding='utf-8') as f: |
94 | 96 | f.write(r"""
|
95 | 97 | <!DOCTYPE html>
|
96 | 98 | <html>
|
|
0 commit comments