Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

Closed
wants to merge 1 commit into from

2 participants

Tai Lee Claude Paroz
Tai Lee

...cts line-by-line.

Claude Paroz
Owner

Thanks, but tests are needed.

Claude Paroz claudep closed this September 04, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 04, 2012
Fixed #8149 -- Use universal line terminators when iterating `File` o…
…bjects line-by-line.
a9f7b1a
This page is out of date. Refresh to see the latest.
4  django/core/files/base.py
@@ -91,9 +91,7 @@ def __iter__(self):
91 91
         # Iterate over this file-like object by newlines
92 92
         buffer_ = None
93 93
         for chunk in self.chunks():
94  
-            chunk_buffer = BytesIO(chunk)
95  
-
96  
-            for line in chunk_buffer:
  94
+            for line in chunk.splitlines(True):
97 95
                 if buffer_:
98 96
                     line = buffer_ + line
99 97
                     buffer_ = None
9  docs/topics/http/file-uploads.txt
@@ -256,10 +256,11 @@ define the following methods/attributes:
256 256
         for line in uploadedfile:
257 257
             do_something_with(line)
258 258
 
259  
-    However, *unlike* standard Python files, :class:`UploadedFile` only
260  
-    understands ``\n`` (also known as "Unix-style") line endings. If you know
261  
-    that you need to handle uploaded files with different line endings, you'll
262  
-    need to do so in your view.
  259
+    .. versionchanged:: 1.5
  260
+
  261
+    In previous versions, :class:`UploadedFile` only understood ``\n`` (also
  262
+    known as "Unix-style") line endings. Now, you can read files line-by-line
  263
+    when they use ``\r`` line endings as well.
263 264
 
264 265
 Upload Handlers
265 266
 ===============
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.