[Python-checkins] python/dist/src/Lib/email FeedParser.py, 1.13, 1.13.2.1 __init__.py, 1.35, 1.35.2.1

bwarsaw at users.sourceforge.net bwarsaw at users.sourceforge.net
Sun Dec 5 04:34:17 CET 2004


Update of /cvsroot/python/python/dist/src/Lib/email
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28099/Lib/email

Modified Files:
      Tag: release24-maint
	FeedParser.py __init__.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: FeedParser.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/FeedParser.py,v
retrieving revision 1.13
retrieving revision 1.13.2.1
diff -u -d -r1.13 -r1.13.2.1
--- FeedParser.py	29 Nov 2004 03:46:54 -0000	1.13
+++ FeedParser.py	5 Dec 2004 03:34:14 -0000	1.13.2.1
@@ -87,6 +87,7 @@
 
     def unreadline(self, line):
         # Let the consumer push a line back into the buffer.
+        assert line is not NeedMoreData
         self._lines.append(line)
 
     def push(self, data):
@@ -242,8 +243,18 @@
                 # EOF.  We want to see if we're at the end of this subpart, so
                 # first consume the blank line, then test the next line to see
                 # if we're at this subpart's EOF.
-                line = self._input.readline()
-                line = self._input.readline()
+                while True:
+                    line = self._input.readline()
+                    if line is NeedMoreData:
+                        yield NeedMoreData
+                        continue
+                    break
+                while True:
+                    line = self._input.readline()
+                    if line is NeedMoreData:
+                        yield NeedMoreData
+                        continue
+                    break
                 if line == '':
                     break
                 # Not at EOF so this is a line we're going to need.

Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/__init__.py,v
retrieving revision 1.35
retrieving revision 1.35.2.1
diff -u -d -r1.35 -r1.35.2.1
--- __init__.py	29 Nov 2004 01:10:14 -0000	1.35
+++ __init__.py	5 Dec 2004 03:34:14 -0000	1.35.2.1
@@ -4,7 +4,7 @@
 
 """A package for parsing, handling, and generating email messages."""
 
-__version__ = '3.0'
+__version__ = '3.0+'
 
 __all__ = [
     'base64MIME',



More information about the Python-checkins mailing list