~paulegan/flufl.bounce/caiwireless-bug-917720

« back to all changes in this revision

Viewing changes to flufl/bounce/_detectors/netscape.py

  • Committer: Barry Warsaw
  • Date: 2012-01-04 16:39:36 UTC
  • Revision ID: barry@python.org-20120104163936-qrrd7ipqrprpxwvp
 * Port to Python 3 is mostly complete, however the test suite current fails
   because of <https://bugs.launchpad.net/zope.interface/+bug/911851>.  Once
   that bug is fixed in `zope.interface`, `flufl.bounce` should be Python 3.2
   compatible without the need for `2to3`.
 * All returned addresses are bytes objects in Python 3 and 8-bit strings in
   Python 2 (no change there).

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
import re
37
37
 
38
 
from cStringIO import StringIO
 
38
from io import BytesIO
39
39
from zope.interface import implements
40
40
 
41
41
from flufl.bounce.interfaces import (
43
43
 
44
44
 
45
45
pcre = re.compile(
46
 
    r'This Message was undeliverable due to the following reason:',
 
46
    b'This Message was undeliverable due to the following reason:',
47
47
    re.IGNORECASE)
48
48
 
49
49
acre = re.compile(
50
 
    r'(?P<reply>please reply to)?.*<(?P<addr>[^>]*)>',
 
50
    b'(?P<reply>please reply to)?.*<(?P<addr>[^>]*)>',
51
51
    re.IGNORECASE)
52
52
 
53
53
 
88
88
        if not plainmsg:
89
89
            return NoFailures
90
90
        # Total guesswork, based on captured examples...
91
 
        body = StringIO(plainmsg.get_payload())
 
91
        body = BytesIO(plainmsg.get_payload(decode=True))
92
92
        addresses = set()
93
93
        for line in body:
94
94
            mo = pcre.search(line)