summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-10-17 18:44:22 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-10-17 18:44:22 (GMT)
commit5c267e2d22e90e4dcdcaef842634371b122970da (patch)
tree0b6758f5df12f8eaf662ef56d5d7e654334d1e99 /Lib
parent9ea8e4c29db12520bdd024357acf354b0653dd04 (diff)
downloadcpython-5c267e2d22e90e4dcdcaef842634371b122970da.zip
cpython-5c267e2d22e90e4dcdcaef842634371b122970da.tar.gz
cpython-5c267e2d22e90e4dcdcaef842634371b122970da.tar.bz2
Close #12454: The mailbox module is now using ASCII, instead of the locale
encoding, to read and write MH mailboxes (.mh_sequences files).
Diffstat (limited to 'Lib')
-rw-r--r--Lib/mailbox.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index e23ea8c..82d6571 100644
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -1108,8 +1108,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:
@@ -1128,13 +1127,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():