summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/pgen2
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-06-16 06:59:01 (GMT)
committerGitHub <noreply@github.com>2017-06-16 06:59:01 (GMT)
commit272d888c7b58aff5e1614e3b12e8198b92054835 (patch)
tree9514cfb06bace475f466f9c8222fb318e8966ee2 /Lib/lib2to3/pgen2
parentfaa63d1e84b273f75d94fe6e66f67a13e4c97f5e (diff)
downloadcpython-272d888c7b58aff5e1614e3b12e8198b92054835.zip
cpython-272d888c7b58aff5e1614e3b12e8198b92054835.tar.gz
cpython-272d888c7b58aff5e1614e3b12e8198b92054835.tar.bz2
bpo-29783: Replace codecs.open() with io.open() (#599)
Diffstat (limited to 'Lib/lib2to3/pgen2')
-rw-r--r--Lib/lib2to3/pgen2/driver.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/Lib/lib2to3/pgen2/driver.py b/Lib/lib2to3/pgen2/driver.py
index a27b9cb..e5e4824 100644
--- a/Lib/lib2to3/pgen2/driver.py
+++ b/Lib/lib2to3/pgen2/driver.py
@@ -94,11 +94,8 @@ class Driver(object):
def parse_file(self, filename, encoding=None, debug=False):
"""Parse a file and return the syntax tree."""
- stream = codecs.open(filename, "r", encoding)
- try:
+ with io.open(filename, "r", encoding=encoding) as stream:
return self.parse_stream(stream, debug)
- finally:
- stream.close()
def parse_string(self, text, debug=False):
"""Parse a string and return the syntax tree."""