Index: Lib/codecs.py =================================================================== --- Lib/codecs.py (révision 79528) +++ Lib/codecs.py (copie de travail) @@ -452,15 +452,8 @@ # read until we get the required number of characters (if available) while True: # can the request can be satisfied from the character buffer? - if chars < 0: - if size < 0: - if self.charbuffer: - break - elif len(self.charbuffer) >= size: - break - else: - if len(self.charbuffer) >= chars: - break + if chars >= 0 and len(self.charbuffer) >= chars: + break # we need more data if size < 0: newdata = self.stream.read() Index: Lib/test/test_codecs.py =================================================================== --- Lib/test/test_codecs.py (révision 79528) +++ Lib/test/test_codecs.py (copie de travail) @@ -118,6 +118,12 @@ size*u"a", ) + # Test readlines() followed by read() + f = getreader("a\n" + "b" * 1000) + self.assertEqual(f.readline(), u"a\n") + self.assertEqual(f.read(), u"b" * 1000) + self.assertEqual(f.read(), u"") + def test_bug1175396(self): s = [ '<%!--===================================================\r\n',