summaryrefslogtreecommitdiffstats
path: root/Lib/email/test/test_email.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2004-12-05 03:45:42 (GMT)
committerBarry Warsaw <barry@python.org>2004-12-05 03:45:42 (GMT)
commit7cf9ce24409efb70efde08e350a4170dc98008a1 (patch)
tree0bb15e7e9f836e06f95db9509b18d21d1d99ec0e /Lib/email/test/test_email.py
parent6c92d76abc730ca7a77da3c7a8627192f7ac3add (diff)
downloadcpython-7cf9ce24409efb70efde08e350a4170dc98008a1.zip
cpython-7cf9ce24409efb70efde08e350a4170dc98008a1.tar.gz
cpython-7cf9ce24409efb70efde08e350a4170dc98008a1.tar.bz2
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.
Diffstat (limited to 'Lib/email/test/test_email.py')
-rw-r--r--Lib/email/test/test_email.py44
1 files changed, 43 insertions, 1 deletions
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
index 2d3841b3..b3a46e6 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -1973,7 +1973,7 @@ class TestIdempotent(TestEmailBase):
# 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 @@ class TestMiscellaneous(unittest.TestCase):
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