Message32081
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'
====================================
|
|
Date |
User |
Action |
Args |
2007-08-23 14:53:56 | admin | link | issue1721862 messages |
2007-08-23 14:53:56 | admin | create | |
|