Bugs item #1076485, was opened at 2004-11-30 23:00 Message generated for change (Comment added) made by bwarsaw You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1076485&group_id=5470
Category: Python Library >Group: Python 2.4 >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Skip Montanaro (montanaro) Assigned to: Barry A. Warsaw (bwarsaw) Summary: Another message that croaks email.FeedParser Initial Comment: 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 ---------------------------------------------------------------------- >Comment By: Barry A. Warsaw (bwarsaw) Date: 2004-12-04 22:30 Message: 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. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1076485&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com