Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document that Response.iter_lines is broken and should be avoided #6570

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/requests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,9 +852,14 @@ def generate():
def iter_lines(
self, chunk_size=ITER_CHUNK_SIZE, decode_unicode=False, 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.
"""Iterates over the response data, one line at a time.

This method is broken and should not be used. It inserts fake
blank lines in unpredictable locations. Furthermore, if
stream=True is set on the request, the results may not be
reproducible. However, the behavior of this method is frozen
and cannot be fixed while preserving strict backward
compatibility. This behavior should be fixed in Requests 3.0.

.. note:: This method is not reentrant safe.
"""
Expand Down