diff options
author | Georg Brandl <georg@python.org> | 2012-03-17 16:58:12 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2012-03-17 16:58:12 +0100 |
commit | ffd4830f6ab0942a463772a01a91f051bfa2d376 (patch) | |
tree | 14d5f982ed3d51197f0dd69370d3f6002aec8e1e /Lib/mailbox.py | |
parent | 206a0cc1b0f2545eef212be6210b4bf7008815ba (diff) | |
parent | 5d6d9423be73e8c6f3f18fa3e006573fc5836236 (diff) | |
download | cpython-ffd4830f6ab0942a463772a01a91f051bfa2d376.tar.gz |
merge with 3.2
Diffstat (limited to 'Lib/mailbox.py')
-rw-r--r-- | Lib/mailbox.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py index a677729386..325b9c9ac0 100644 --- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -1106,8 +1106,7 @@ class MH(Mailbox): def get_sequences(self): """Return a name-to-key-list dictionary to define each sequence.""" results = {} - f = open(os.path.join(self._path, '.mh_sequences'), 'r') - try: + with open(os.path.join(self._path, '.mh_sequences'), 'r', encoding='ASCII') as f: all_keys = set(self.keys()) for line in f: try: @@ -1126,13 +1125,11 @@ class MH(Mailbox): except ValueError: raise FormatError('Invalid sequence specification: %s' % line.rstrip()) - finally: - f.close() return results def set_sequences(self, sequences): """Set sequences using the given name-to-key-list dictionary.""" - f = open(os.path.join(self._path, '.mh_sequences'), 'r+') + f = open(os.path.join(self._path, '.mh_sequences'), 'r+', encoding='ASCII') try: os.close(os.open(f.name, os.O_WRONLY | os.O_TRUNC)) for name, keys in sequences.items(): |