diff options
| author | Barry Warsaw | 2007-09-19 07:28:58 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2007-09-19 07:28:58 -0400 |
| commit | 4c517789fa8b29d2a23791e6f390d9f1173c3125 (patch) | |
| tree | 9b5c1ed27416cbec12665a1cea5206336d72c039 /Mailman/Deliverer.py | |
| parent | 39c87b16da60a5274bfc7494d0a121b3162b56fb (diff) | |
| download | mailman-4c517789fa8b29d2a23791e6f390d9f1173c3125.tar.gz mailman-4c517789fa8b29d2a23791e6f390d9f1173c3125.tar.zst mailman-4c517789fa8b29d2a23791e6f390d9f1173c3125.zip | |
Diffstat (limited to 'Mailman/Deliverer.py')
| -rw-r--r-- | Mailman/Deliverer.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/Mailman/Deliverer.py b/Mailman/Deliverer.py index c9b044286..e543f5793 100644 --- a/Mailman/Deliverer.py +++ b/Mailman/Deliverer.py @@ -18,6 +18,8 @@ """Mixin class with message delivery routines.""" +from __future__ import with_statement + import logging from email.MIMEMessage import MIMEMessage @@ -126,9 +128,7 @@ action by you is required."""))) except Errors.MMListError: # Oh well return - otrans = i18n.get_translation() - i18n.set_language(mlist.preferred_language) - try: + with i18n.using_language(mlist.preferred_language): msg = Message.OwnerNotification( mlist, _('Hostile subscription attempt detected'), @@ -137,8 +137,6 @@ deliberate malicious attempt, they tried to confirm the invitation to a different list. We just thought you'd like to know. No further action by you is required."""))) msg.send(mlist) - finally: - i18n.set_translation(otrans) def sendProbe(self, member, msg): listname = self.real_name @@ -162,12 +160,8 @@ is required."""))) self.host_name) # Calculate the Subject header, in the member's preferred language ulang = self.getMemberLanguage(member) - otrans = i18n.get_translation() - i18n.set_language(ulang) - try: + with i18n.using_language(ulang): subject = _('%(listname)s mailing list probe message') - finally: - i18n.set_translation(otrans) outer = Message.UserNotification(member, probeaddr, subject, lang=ulang) outer.set_type('multipart/mixed') |
