summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2013-02-12 01:04:27 (GMT)
committerGiampaolo Rodola' <g.rodola@gmail.com>2013-02-12 01:04:27 (GMT)
commit2f50aaf2ff427fb713e82699a6dcbeeb038b10c2 (patch)
tree0e2c24897b8918f19d8504915ccebd466c0bbd92 /Lib/lib2to3
parentfd6e6cfa29b2289e711dc7f57f36897c78899ee7 (diff)
downloadcpython-2f50aaf2ff427fb713e82699a6dcbeeb038b10c2.zip
cpython-2f50aaf2ff427fb713e82699a6dcbeeb038b10c2.tar.gz
cpython-2f50aaf2ff427fb713e82699a6dcbeeb038b10c2.tar.bz2
modernize some modules' code by using with statement around open()
Diffstat (limited to 'Lib/lib2to3')
-rw-r--r--Lib/lib2to3/pgen2/grammar.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/Lib/lib2to3/pgen2/grammar.py b/Lib/lib2to3/pgen2/grammar.py
index 26caeb4..5ad21ff 100644
--- a/Lib/lib2to3/pgen2/grammar.py
+++ b/Lib/lib2to3/pgen2/grammar.py
@@ -86,15 +86,13 @@ class Grammar(object):
def dump(self, filename):
"""Dump the grammar tables to a pickle file."""
- f = open(filename, "wb")
- pickle.dump(self.__dict__, f, 2)
- f.close()
+ with open(filename, "wb") as f:
+ pickle.dump(self.__dict__, f, 2)
def load(self, filename):
"""Load the grammar tables from a pickle file."""
- f = open(filename, "rb")
- d = pickle.load(f)
- f.close()
+ with open(filename, "rb") as f:
+ d = pickle.load(f)
self.__dict__.update(d)
def copy(self):