Kaydet (Commit) 90a9f81d authored tarafından Russell Keith-Magee's avatar Russell Keith-Magee

Fixed #12147 -- Replaced use of try-except-finally to allow for Python 2.4…

Fixed #12147 -- Replaced use of try-except-finally to allow for Python 2.4 support. Thanks to knutin for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11721 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst dd5d7622
...@@ -18,17 +18,20 @@ class EmailBackend(BaseEmailBackend): ...@@ -18,17 +18,20 @@ class EmailBackend(BaseEmailBackend):
return return
self._lock.acquire() self._lock.acquire()
try: try:
stream_created = self.open() # The try-except is nested to allow for
for message in email_messages: # Python 2.4 support (Refs #12147)
self.stream.write('%s\n' % message.message().as_string()) try:
self.stream.write('-'*79) stream_created = self.open()
self.stream.write('\n') for message in email_messages:
self.stream.flush() # flush after each message self.stream.write('%s\n' % message.message().as_string())
if stream_created: self.stream.write('-'*79)
self.close() self.stream.write('\n')
except: self.stream.flush() # flush after each message
if not self.fail_silently: if stream_created:
raise self.close()
except:
if not self.fail_silently:
raise
finally: finally:
self._lock.release() self._lock.release()
return len(email_messages) return len(email_messages)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment