You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I modified iter_lines as follows, and the above test passes:
defiter_lines(self, chunk_size=ITER_CHUNK_SIZE, decode_unicode=None, delimiter=None):
"""Iterates over the response data, one line at a time. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. .. note:: This method is not reentrant safe. """pending=Noneforchunkinself.iter_content(chunk_size=chunk_size, decode_unicode=decode_unicode):
ifpendingisnotNone:
chunk=pending+chunkifdelimiter:
lines=chunk.split(delimiter)
else:
lines=chunk.splitlines()
iflinesandlines[-1] andchunkandlines[-1][-1] ==chunk[-1]:
pending=lines.pop()
eliflinesandlines[-1] =='':
pending=lines.pop()
else:
pending=Noneforlineinlines:
yieldlineifpendingisnotNone:
yieldpending
This command is only available on Requests v2.16.4 and greater. Otherwise,
please provide some basic information about your system (Python version,
operating system, &c).
The text was updated successfully, but these errors were encountered:
Hey @a-p-f, thanks for putting together such a detailed issue. This is actually a duplicate of #3980 and addressed by #3984. This is a breaking change though, so it won't be available until 3.0.0 is released.
I'm going to close this out as a dupe, but please let us know if you have any further questions.
When using iter_lines with chunk_size other than None, it can generate an extra blank line if the end of a chunk lands on a delimiter.
Reproduction Steps
Expected Result
['a', 'b']
['a', 'b']
Actual Result
['a', 'b']
['a', '', 'b']
Proposed Fix
I modified iter_lines as follows, and the above test passes:
System Information
This command is only available on Requests v2.16.4 and greater. Otherwise,
please provide some basic information about your system (Python version,
operating system, &c).
The text was updated successfully, but these errors were encountered: