summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2014-09-29 18:24:33 -0700
committerTim Graham <timograham@gmail.com>2014-10-30 11:52:59 -0400
commiteb4f6de980c5148ba48d4ed67f31cca27dd132a8 (patch)
tree787358de9347c8fcfd0bb5fa8c12778f90bf15d3 /docs
parenteab3dc195eff4123460fb99d7819a7f6627e7115 (diff)
Fixed #8149 -- Made File.__iter__() support universal newlines.
The following are recognized as ending a line: the Unix end-of-line convention '\n', the Windows convention '\r\n', and the old Macintosh convention '\r'. http://www.python.org/dev/peps/pep-0278 Thanks tchaumeny for review.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/files/file.txt9
-rw-r--r--docs/ref/files/uploads.txt13
-rw-r--r--docs/releases/1.8.txt7
3 files changed, 25 insertions, 4 deletions
diff --git a/docs/ref/files/file.txt b/docs/ref/files/file.txt
index 6874936eab..57f8e9eab3 100644
--- a/docs/ref/files/file.txt
+++ b/docs/ref/files/file.txt
@@ -53,6 +53,15 @@ The ``File`` Class
Iterate over the file yielding one line at a time.
+ .. versionchanged:: 1.8
+
+ ``File`` now uses `universal newlines`_. The following are
+ recognized as ending a line: the Unix end-of-line convention
+ ``'\n'``, the Windows convention ``'\r\n'``, and the old Macintosh
+ convention ``'\r'``.
+
+ .. _universal newlines: http://www.python.org/dev/peps/pep-0278
+
.. method:: chunks([chunk_size=None])
Iterate over the file yielding "chunks" of a given size. ``chunk_size``
diff --git a/docs/ref/files/uploads.txt b/docs/ref/files/uploads.txt
index 1b9103bb3b..0817816197 100644
--- a/docs/ref/files/uploads.txt
+++ b/docs/ref/files/uploads.txt
@@ -82,10 +82,15 @@ Here are some useful attributes of ``UploadedFile``:
for line in uploadedfile:
do_something_with(line)
- 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.
+ Lines are split using `universal newlines`_. The following are recognized
+ as ending a line: the Unix end-of-line convention ``'\n'``, the Windows
+ convention ``'\r\n'``, and the old Macintosh convention ``'\r'``.
+
+ .. _universal newlines: http://www.python.org/dev/peps/pep-0278
+
+ .. versionchanged:: 1.8
+
+ Previously lines were only split on the Unix end-of-line ``'\n'``.
Subclasses of ``UploadedFile`` include:
diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt
index 23c6deeef1..dbdff7b7e0 100644
--- a/docs/releases/1.8.txt
+++ b/docs/releases/1.8.txt
@@ -659,6 +659,13 @@ Miscellaneous
* By default, :ref:`call_command <call-command>` now always skips the check
framework (unless you pass it ``skip_checks=False``).
+* When iterating over lines, :class:`~django.core.files.File` now uses
+ `universal newlines`_. The following are recognized as ending a line: the
+ Unix end-of-line convention ``'\n'``, the Windows convention ``'\r\n'``, and
+ the old Macintosh convention ``'\r'``.
+
+ .. _universal newlines: http://www.python.org/dev/peps/pep-0278
+
.. _deprecated-features-1.8:
Features deprecated in 1.8