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: Another message that croaks email.FeedParser
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-12-01 04:00 by skip.montanaro, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
msg.4 skip.montanaro, 2004-12-01 04:00
Messages (2)
msg23410 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2004-12-01 04:00
The attached message causes a TypeError exception with the
email.FeedParser class that comes with Python 2.4.  The
traceback
I get is:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/Users/skip/local/lib/python2.4/mailbox.py",
line 35, in next
    return self.factory(_Subfile(self.fp, start, stop))
  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 43, in message_from_string
    return Parser(*args, **kws).parsestr(s)
  File
"/Users/skip/local/lib/python2.4/email/Parser.py", line
79, in parsestr
    return self.parse(StringIO(text),
headersonly=headersonly)
  File
"/Users/skip/local/lib/python2.4/email/Parser.py", line
68, in parse
    feedparser.feed(data)
  File
"/Users/skip/local/lib/python2.4/email/FeedParser.py",
line 146, in feed
    self._call_parse()
  File
"/Users/skip/local/lib/python2.4/email/FeedParser.py",
line 150, in _call_parse
    self._parse()
  File
"/Users/skip/local/lib/python2.4/email/FeedParser.py",
line 331, in _parsegen
    for retval in self._parsegen():
  File
"/Users/skip/local/lib/python2.4/email/FeedParser.py",
line 228, in _parsegen
    for retval in self._parsegen():
  File
"/Users/skip/local/lib/python2.4/email/FeedParser.py",
line 190, in _parsegen
    for line in self._input:
  File
"/Users/skip/local/lib/python2.4/email/FeedParser.py",
line 119, in next
    line = self.readline()
  File
"/Users/skip/local/lib/python2.4/email/FeedParser.py",
line 79, in readline
    if ateof(line):
TypeError: expected string or buffer
msg23411 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2004-12-05 03:30
Logged In: YES 
user_id=12800

I have a fix for this which I'll commit to the CVS head and
release24-maint.  The problem is caused by a place where
readline() could have returned NeedsMoreData, but that case
wasn't being checked.  If you use email.message_from_*, that
uses the Parser interface, which reads the text in 8192 byte
chunks.  The test message just happens to have the first
8192 chunk fall inside a line in the
message/delivery-status, which was the block that had the
readline() that failed to check for NeedsMoreData.

BTW, you can work around this by using the FeedParser
interface directly, since that doesn't chunk the input.
History
Date User Action Args
2022-04-11 14:56:08adminsetgithub: 41257
2004-12-01 04:00:31skip.montanarocreate