This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: New email pkg FeedParser croaks on some spam
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: barry Nosy List: barry, skip.montanaro
Priority: normal Keywords:

Created on 2004-05-15 04:19 by skip.montanaro, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
spam10 skip.montanaro, 2004-05-15 04:19
FeedParser.diff skip.montanaro, 2004-05-15 15:59
Messages (4)
msg20803 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2004-05-15 04:19
After cvs up today, the Spambayes sb_filter.py app
croaks on the attached spam (spam10).  I suspect
it's got something to do with the new FeedParser
in the email package.

Running 'sb_filter.py spam10' I get this traceback:

Traceback (most recent call last):
  File "/Users/skip/local/bin/sb_filter.py", line 257, in ?
    main()
  File "/Users/skip/local/bin/sb_filter.py", line 245, in main
    mbox = mboxutils.getmbox(fname)
  File "/Users/skip/local/lib/python2.4/site-packages/
spambayes/mboxutils.py", line 66, in getmbox
    return [get_message(sys.stdin)]
  File "/Users/skip/local/lib/python2.4/site-packages/
spambayes/mboxutils.py", line 129, in get_message
    msg = email.message_from_string(obj)
  File "/Users/skip/local/lib/python2.4/email/__init__.py", 
line 45, in message_from_string
    return Parser(_class, strict=strict).parsestr(s)
  File "/Users/skip/local/lib/python2.4/email/Parser.py", line 
67, in parsestr
    return self.parse(StringIO(text), 
headersonly=headersonly)
  File "/Users/skip/local/lib/python2.4/email/Parser.py", line 
56, in parse
    feedparser.feed(data)
  File "/Users/skip/local/lib/python2.4/email/FeedParser.py", 
line 145, in feed
    self._call_parse()
  File "/Users/skip/local/lib/python2.4/email/FeedParser.py", 
line 149, in _call_parse
    self._parse()
  File "/Users/skip/local/lib/python2.4/email/FeedParser.py", 
line 317, in _parsegen
    mo = boundaryre.match(line)
TypeError: expected string or buffer
msg20804 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2004-05-15 15:59
Logged In: YES 
user_id=44345

After looking at the source, this error seems to be pretty
shallow.  Attached is FeedParser.diff, which seems to 
fix the problem.
msg20805 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2004-05-15 16:18
Logged In: YES 
user_id=12800

That's exactly the right fix -- I have the same one waiting
to be checked in, but I've been trying to boil down the
example so I can add it to the test suite.
msg20806 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2004-05-15 16:28
Logged In: YES 
user_id=12800

Actually, I won't add a test case for this one -- it'll
happens because of the 8092 byte blocking factor of
Parser.parse().
History
Date User Action Args
2022-04-11 14:56:04adminsetgithub: 40256
2004-05-15 04:19:42skip.montanarocreate