diff options
Diffstat (limited to 'Lib/lib2to3/pgen2/driver.py')
-rw-r--r-- | Lib/lib2to3/pgen2/driver.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/lib2to3/pgen2/driver.py b/Lib/lib2to3/pgen2/driver.py index 3cff0ac..6b3825e 100644 --- a/Lib/lib2to3/pgen2/driver.py +++ b/Lib/lib2to3/pgen2/driver.py @@ -16,6 +16,7 @@ __author__ = "Guido van Rossum <guido@python.org>" __all__ = ["Driver", "load_grammar"] # Python imports +import codecs import os import logging import sys @@ -41,7 +42,7 @@ class Driver(object): lineno = 1 column = 0 type = value = start = end = line_text = None - prefix = "" + prefix = u"" for quintuple in tokens: type, value, start, end, line_text = quintuple if start != (lineno, column): @@ -90,9 +91,9 @@ class Driver(object): """Parse a stream and return the syntax tree.""" return self.parse_stream_raw(stream, debug) - def parse_file(self, filename, debug=False): + def parse_file(self, filename, encoding=None, debug=False): """Parse a file and return the syntax tree.""" - stream = open(filename) + stream = codecs.open(filename, "r", encoding) try: return self.parse_stream(stream, debug) finally: |