[Python-checkins]
python/dist/src/Lib/email/test test_email.py, 1.67, 1.68
bwarsaw at users.sourceforge.net
bwarsaw at users.sourceforge.net
Sun Dec 5 04:45:44 CET 2004
Update of /cvsroot/python/python/dist/src/Lib/email/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29909/Lib/email/test
Modified Files:
test_email.py
Log Message:
Fixes for SF #1076485, which I'll apply to the CVS head too. The problem was
caused by a self._input.readline() call that wasn't checking for the
NeedsMoreData marker.
msg_43.txt contains a message that illustrates the problem, when
email.message_from_*() is called. That interface uses the Parser API, which
splits reads into 8192 byte chunks. It so happens that for the test message,
the 8192 chunk falls inside a message/delivery-status, which is where in the
FeedParser the readline() call was that didn't check for NeedsMoreData.
I also added an assert to unreadline() so it'll be more evident if an attempt
to push back NeedsMoreData ever happens again.
Bump the email package version number.
Index: test_email.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/test/test_email.py,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- test_email.py 29 Nov 2004 03:46:54 -0000 1.67
+++ test_email.py 5 Dec 2004 03:45:42 -0000 1.68
@@ -1973,7 +1973,7 @@
# Test various other bits of the package's functionality
-class TestMiscellaneous(unittest.TestCase):
+class TestMiscellaneous(TestEmailBase):
def test_message_from_string(self):
fp = openfile('msg_01.txt')
try:
@@ -2222,6 +2222,48 @@
uc = Charset('US-ASCII')
self.assertEqual(lc.get_body_encoding(), uc.get_body_encoding())
+ def test_partial_falls_inside_message_delivery_status(self):
+ eq = self.ndiffAssertEqual
+ # The Parser interface provides chunks of data to FeedParser in 8192
+ # byte gulps. SF bug #1076485 found one of those chunks inside
+ # message/delivery-status header block, which triggered an
+ # unreadline() of NeedMoreData.
+ msg = self._msgobj('msg_43.txt')
+ sfp = StringIO()
+ Iterators._structure(msg, sfp)
+ eq(sfp.getvalue(), """\
+multipart/report
+ text/plain
+ message/delivery-status
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+ text/rfc822-headers
+""")
+
# Test the iterator/generators
More information about the Python-checkins
mailing list