diff options
author | Larry Hastings <larry@hastings.org> | 2014-01-27 06:28:06 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2014-01-27 06:28:06 (GMT) |
commit | 23105d801432740c5ed61b56d8f6fb9f6cf6923e (patch) | |
tree | 560577ab65b1a1bdbd87c337d2773ce8e5724917 /Lib/codecs.py | |
parent | ee4cca6e33b2b2c114ec8736a76263f92b37c4aa (diff) | |
parent | 71215c584ad94cdfe34cfa5ab522f7c36f2df0c7 (diff) | |
download | cpython-23105d801432740c5ed61b56d8f6fb9f6cf6923e.zip cpython-23105d801432740c5ed61b56d8f6fb9f6cf6923e.tar.gz cpython-23105d801432740c5ed61b56d8f6fb9f6cf6923e.tar.bz2 |
Merge.
Diffstat (limited to 'Lib/codecs.py')
-rw-r--r-- | Lib/codecs.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Lib/codecs.py b/Lib/codecs.py index 2e2e755..c2065da 100644 --- a/Lib/codecs.py +++ b/Lib/codecs.py @@ -475,15 +475,12 @@ class StreamReader(Codec): # read until we get the required number of characters (if available) while True: # can the request be satisfied from the character buffer? - if chars < 0: - if size < 0: - if self.charbuffer: - break - elif len(self.charbuffer) >= size: - break - else: + if chars >= 0: if len(self.charbuffer) >= chars: break + elif size >= 0: + if len(self.charbuffer) >= size: + break # we need more data if size < 0: newdata = self.stream.read() @@ -491,6 +488,8 @@ class StreamReader(Codec): newdata = self.stream.read(size) # decode bytes (those remaining from the last call included) data = self.bytebuffer + newdata + if not data: + break try: newchars, decodedbytes = self.decode(data, self.errors) except UnicodeDecodeError as exc: |