~syst3mw0rm/mailman/bug-890675

« back to all changes in this revision

Viewing changes to src/mailman/runners/bounce.py

  • Committer: Barry Warsaw
  • Date: 2012-01-07 18:47:51 UTC
  • mfrom: (7066.1.3 auth)
  • Revision ID: barry@list.org-20120107184751-tz4n7xw3a63wt0ay
- Bump copyright years.
- Refactor to use the flufl.password package.
- Adapt to the API for flufl.bounce 2.0.
- Add a `bin/mailman shell` alias for `bin/mailman withlist`.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2001-2011 by the Free Software Foundation, Inc.
 
1
# Copyright (C) 2001-2012 by the Free Software Foundation, Inc.
2
2
#
3
3
# This file is part of GNU Mailman.
4
4
#
70
70
                # done.s
71
71
                addresses = scan_message(msg)
72
72
        # If that still didn't return us any useful addresses, then send it on
73
 
        # or discard it.
 
73
        # or discard it.  The addresses will come back from flufl.bounce as
 
74
        # bytes/8-bit strings, but we must store them as unicodes in the
 
75
        # database.  Assume utf-8 encoding, but be cautious.
74
76
        if len(addresses) > 0:
75
77
            for address in addresses:
 
78
                if isinstance(address, bytes):
 
79
                    try:
 
80
                        address = address.decode('utf-8')
 
81
                    except UnicodeError:
 
82
                        log.exception('Ignoring non-UTF-8 encoded '
 
83
                                      'address: {0}'.format(address))
 
84
                        continue
76
85
                self._processor.register(mlist, address, msg, context)
77
86
        else:
78
87
            log.info('Bounce message w/no discernable addresses: %s',