1
0
mirror of https://github.com/django/django.git synced 2025-04-01 12:06:43 +00:00

[1.8.x] Refs #23763 -- Fixed Python 3.5 PendingDeprecationWarning in LazyStream.

Fixed "PendingDeprecationWarning: generator 'LazyStream.read.<locals>.parts'
raised StopIteration" per PEP 0479.

Backport of 3f2de803181ca3c5526ec9d708b2098b8f683808 from master
This commit is contained in:
Tim Graham 2015-06-16 11:46:32 -04:00
parent e2ea30c440
commit 2a36a9bb15

View File

@ -327,12 +327,15 @@ class LazyStream(six.Iterator):
while remaining != 0:
assert remaining > 0, 'remaining bytes to read should never go negative'
chunk = next(self)
emitting = chunk[:remaining]
self.unget(chunk[remaining:])
remaining -= len(emitting)
yield emitting
try:
chunk = next(self)
except StopIteration:
return
else:
emitting = chunk[:remaining]
self.unget(chunk[remaining:])
remaining -= len(emitting)
yield emitting
out = b''.join(parts())
return out