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.

Author syeberman
Recipients
Date 2007-05-19.16:06:25
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
When email.FeedParser.BufferedSubFile sees "\r" at the end of the pushed-in data, it assumes that it is a Macintosh-style line terminator.  Instead, it should request more data, to ensure that the next character is not "\n", which would make it a Windows-style line terminator.  This affects email.message_from_file, which reads in the data in 8192 byte chunks.  The following code demonstrates this:

====================================
from StringIO import StringIO
from email.FeedParser import \
    BufferedSubFile, NeedMoreData

fp = StringIO( "1\r\n10\r\n100\r\n"
               "1000\r\n10000\r\n" )
bsf = BufferedSubFile( )
while True:
    data = fp.read( 3 )
    if not data:
        break
    bsf.push( data )
    for line in bsf:
        if line is NeedMoreData:
            break
        print repr( line )
bsf.close()
====================================

The output is:
====================================
'1\r\n'
'10\r'
'\n'
'100\r\n'
'1000\r\n'
'10000\r'
'\n'
====================================


History
Date User Action Args
2007-08-23 14:53:56adminlinkissue1721862 messages
2007-08-23 14:53:56admincreate