Skip to content

Commit 74e239d

Browse files
author
Giovanni Siragusa
committed
Safely decode if the input or the buffer is None.
1 parent dc03ce7 commit 74e239d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Lib/codecs.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,13 @@ def _buffer_decode(self, input, errors, final):
321321

322322
def decode(self, input, final=False):
323323
# decode input (taking the buffer into account)
324-
data = self.buffer + input
324+
data = b''
325+
if input is not None:
326+
data += input
327+
328+
if self.buffer is not None:
329+
data += self.buffer
330+
325331
(result, consumed) = self._buffer_decode(data, self.errors, final)
326332
# keep undecoded input until the next call
327333
self.buffer = data[consumed:]

0 commit comments

Comments
 (0)