Patches item #632934, was opened at 2002-11-03 17:50 Message generated for change (Comment added) made by loewis You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=632934&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: Library (Lib) Group: Python 2.3 >Status: Closed >Resolution: Works For Me Priority: 5 Private: No Submitted By: R�mi Peyronnet (rpeyron) Assigned to: Barry A. Warsaw (bwarsaw) 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: Martin v. Löwis (loewis) Date: 2006-11-05 19:47 Message: Logged In: YES user_id=21627 After reviewing the code, I cannot see a reason for this problem to occur. self.stop originates from an earlier fp.tell() call, so it should be at most equal to the file size. Later readline calls should manage to read all of the file, then fp.tell should report the same value. The only way this might happen is that self.stop was somehow modified outside the standard library, or a _Subfile was created externally; I don't think the library should work around such a problem. So closing this as "works for me". If somebody manages to reproduce the problem, please include precise instructions on how to reproduce it. ---------------------------------------------------------------------- Comment By: R�mi Peyronnet (rpeyron) Date: 2004-11-22 23:51 Message: Logged In: YES user_id=641559 Sorry, I did not keep the mailbox. I may re-use this script in a few weeks/months, and if it does the same thing I will attach one. ---------------------------------------------------------------------- Comment By: Johannes Gijsbers (jlgijsbers) Date: 2004-11-11 21:29 Message: Logged In: YES user_id=469548 R�mi, could you attach the mailbox (or a similar mailbox) that triggers the problem? ---------------------------------------------------------------------- Comment By: Tim Peters (tim_one) Date: 2004-03-21 21:03 Message: Logged In: YES user_id=31435 Assigned to Barry. Maybe y'all can polish this one off during the email sprint? ---------------------------------------------------------------------- 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
_______________________________________________ Patches mailing list [email protected] http://mail.python.org/mailman/listinfo/patches
