[Patches] [ python-Patches-632934 ] Problem at the end of misformed mailbox

SourceForge.net noreply at sourceforge.net
Sat Dec 27 13:48:06 EST 2003


Patches item #632934, was opened at 2002-11-03 17:50
Message generated for change (Comment added) made by rpeyron
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=632934&group_id=5470

Category: Library (Lib)
>Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Rémi Peyronnet (rpeyron)
Assigned to: Nobody/Anonymous (nobody)
Summary: Problem at the end of misformed mailbox

Initial Comment:
I had a problem with a not well formed mailbox (maybe 
ambiguous carriage return chars, due to both use under 
windows and linux) : the function mailbox.readlines 
(lib/mailbox.py:66) entered in an indefinite cycle.

I found that the self.stop value was too big for the file, 
and that the index of self.pos could not go that far. The 
function readlines will call ever and ever readline, which 
will return always the same 1-length string.

I solved this by comparing the fp.pos before and after 
the read operation. If it the same, we re probably at the 
end of the file, or there is a problem, and we should go 
out.

As I do not know much about the Python internals, the 
following patch may not be good :

C:\Python222\Lib>diff "Copie de mailbox.py"  mailbox.py
63c63,68
<         self.pos = self.fp.tell()
---
>         data = self.fp.readline(length)
>         self_fp_tell = self.fp.tell()
>         if self.pos == self_fp_tell:
>           return ''
>         else:
>           self.pos = self_fp_tell

Regards

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

>Comment By: Rémi Peyronnet (rpeyron)
Date: 2003-12-27 19:48

Message:
Logged In: YES 
user_id=641559

This problem seems to exist in 2.3 version too.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=632934&group_id=5470



More information about the Patches mailing list