diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-03-14 15:33:54 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2018-03-14 15:33:54 -0700 |
commit | f454b094912a3fdf56c9123b9226f6dfa3f28d5d (patch) | |
tree | 87f54182bd259a8c7424e48783713fb558331204 /alot | |
parent | d3f87ad82432a773cc69808135454f6bb104880e (diff) |
fix saving attachments
Attachments are encoded into bytes, but the file we open to write them
into was being opened in text mode. That doesn't work. Open the file in
bytes mode instead.
Diffstat (limited to 'alot')
-rw-r--r-- | alot/db/attachment.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/alot/db/attachment.py b/alot/db/attachment.py index b35092e5..1181a125 100644 --- a/alot/db/attachment.py +++ b/alot/db/attachment.py @@ -68,11 +68,11 @@ class Attachment(object): if os.path.isdir(path): if filename: basename = os.path.basename(filename) - file_ = open(os.path.join(path, basename), "w") + file_ = open(os.path.join(path, basename), "wb") else: file_ = tempfile.NamedTemporaryFile(delete=False, dir=path) else: - file_ = open(path, "w") # this throws IOErrors for invalid path + file_ = open(path, "wb") # this throws IOErrors for invalid path self.write(file_) file_.close() return file_.name |