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 draghuram
Recipients amaury.forgeotdarc, christian.heimes, draghuram, gvanrossum
Date 2007-11-06.04:36:31
SpamBayes Score 0.028091185
Marked as misclassified No
Message-id <1194323792.55.0.580361470916.issue1395@psf.upfronthosting.co.za>
In-reply-to
Content
I think the solution is to do the translation on a bigger chunk than on
the string being returned in each read call. For example, the following
patch correctly returns "a" and "\n" (instead of "a" and two "\n"s). 

Index: Lib/io.py
===================================================================
--- Lib/io.py   (revision 58874)
+++ Lib/io.py   (working copy)
@@ -1253,8 +1253,9 @@
                 res += pending
                 if not readahead:
                     break
+            res = self._replacenl(res)
             self._pending = res[n:]
-            return self._replacenl(res[:n])
+            return res[:n]

     def __next__(self):
         self._telling = False

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

Of course, we need to take care of the case when the last character in
"res" is "\r" to be followed by "\n" in the next read. I just wanted to
see if I am on the right track and if so, I can spend more time on this.
History
Date User Action Args
2007-11-06 04:36:32draghuramsetspambayes_score: 0.0280912 -> 0.028091185
recipients: + draghuram, gvanrossum, amaury.forgeotdarc, christian.heimes
2007-11-06 04:36:32draghuramsetspambayes_score: 0.0280912 -> 0.0280912
messageid: <1194323792.55.0.580361470916.issue1395@psf.upfronthosting.co.za>
2007-11-06 04:36:32draghuramlinkissue1395 messages
2007-11-06 04:36:31draghuramcreate