Bugs item #1721862, was opened at 2007-05-19 11:06
Message generated for change (Comment added) made by syeberman
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1721862&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Sye van der Veen (syeberman)
Assigned to: Nobody/Anonymous (nobody)
Summary: email.FeedParser.BufferedSubFile improperly handles "\r\n"

Initial Comment:
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'
====================================




----------------------------------------------------------------------

>Comment By: Sye van der Veen (syeberman)
Date: 2007-05-19 11:09

Message:
Logged In: YES 
user_id=982447
Originator: YES

File Added: BufferedSubFileBug.py

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1721862&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to