Skip to content


Fixed #8149 -- Use universal line terminators when iterating `File` obje... #320

wants to merge 1 commit into from

2 participants


...cts line-by-line.

Django member

Thanks, but tests are needed.

@claudep claudep closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 4, 2012
  1. Fixed #8149 -- Use universal line terminators when iterating `File` o…

    Tai Lee committed
    …bjects line-by-line.
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 7 deletions.
  1. +1 −3 django/core/files/
  2. +5 −4 docs/topics/http/file-uploads.txt
4 django/core/files/
@@ -91,9 +91,7 @@ def __iter__(self):
# Iterate over this file-like object by newlines
buffer_ = None
for chunk in self.chunks():
- chunk_buffer = BytesIO(chunk)
- for line in chunk_buffer:
+ for line in chunk.splitlines(True):
if buffer_:
line = buffer_ + line
buffer_ = None
9 docs/topics/http/file-uploads.txt
@@ -256,10 +256,11 @@ define the following methods/attributes:
for line in uploadedfile:
- However, *unlike* standard Python files, :class:`UploadedFile` only
- understands ``\n`` (also known as "Unix-style") line endings. If you know
- that you need to handle uploaded files with different line endings, you'll
- need to do so in your view.
+ .. versionchanged:: 1.5
+ In previous versions, :class:`UploadedFile` only understood ``\n`` (also
+ known as "Unix-style") line endings. Now, you can read files line-by-line
+ when they use ``\r`` line endings as well.
Upload Handlers
Something went wrong with that request. Please try again.