Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…n 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
  • Loading branch information...
commit 90a9f81d377b17c0df08faac5aa0fdd412508123 1 parent dd5d762
@freakboy3742 freakboy3742 authored
Showing with 14 additions and 11 deletions.
  1. +14 −11 django/core/mail/backends/console.py
View
25 django/core/mail/backends/console.py
@@ -18,17 +18,20 @@ def send_messages(self, email_messages):
return
self._lock.acquire()
try:
- stream_created = self.open()
- for message in email_messages:
- self.stream.write('%s\n' % message.message().as_string())
- self.stream.write('-'*79)
- self.stream.write('\n')
- self.stream.flush() # flush after each message
- if stream_created:
- self.close()
- except:
- if not self.fail_silently:
- raise
+ # The try-except is nested to allow for
+ # Python 2.4 support (Refs #12147)
+ try:
+ stream_created = self.open()
+ for message in email_messages:
+ self.stream.write('%s\n' % message.message().as_string())
+ self.stream.write('-'*79)
+ self.stream.write('\n')
+ self.stream.flush() # flush after each message
+ if stream_created:
+ self.close()
+ except:
+ if not self.fail_silently:
+ raise
finally:
self._lock.release()
return len(email_messages)
Please sign in to comment.
Something went wrong with that request. Please try again.