Skip to content

Commit 83853be

Browse files
author
Yamil Asusta
committed
Merge pull request #89 from cbg/attachment_name_encoding
Encode unicode object file attachment names to Python str objects
2 parents bdab36b + aa3d5c1 commit 83853be

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

sendgrid/message.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def set_replyto(self, replyto):
119119
self.reply_to = replyto
120120

121121
def add_attachment(self, name, file_):
122+
if sys.version_info < (3, 0) and isinstance(name, unicode):
123+
name = name.encode('utf-8')
122124
if isinstance(file_, str): # filepath
123125
with open(file_, 'rb') as f:
124126
self.files[name] = f.read()

0 commit comments

Comments
 (0)