diff Lib/codecs.py @ 36856:fe0736ccba75 2.4

Backport revision 42872: If size is specified, try to read at least size characters. This is a alternative version of patch #1379332.
author Walter Dörwald <walter@livinglogic.de>
date Mon, 06 Mar 2006 22:44:03 +0000
parents 4806cb009a9c
children 72a720dd64fb
line wrap: on
line diff
--- a/Lib/codecs.py	Mon Mar 06 00:55:25 2006 +0000
+++ b/Lib/codecs.py	Mon Mar 06 22:44:03 2006 +0000
@@ -274,7 +274,10 @@
         while True:
             # can the request can be satisfied from the character buffer?
             if chars < 0:
-                if self.charbuffer:
+                if size < 0:
+                    if self.charbuffer:
+                        break
+                elif len(self.charbuffer) >= size:
                     break
             else:
                 if len(self.charbuffer) >= chars: