summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJosh Schneier <josh.schneier@gmail.com>2017-04-26 14:17:41 -0400
committerTim Graham <timograham@gmail.com>2017-04-26 19:39:22 -0400
commita1b2c1d76ec4b7ca396b015a0616a1f8a1845066 (patch)
treefaaf81c21a80311ecd8582c7f77666fdc4487280 /django
parent278a09ac1f410cf4e3472146324feded2e2c18b3 (diff)
Fixed #28137 -- Deprecated HttpRequest.xreadlines().
Diffstat (limited to 'django')
-rw-r--r--django/http/request.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/django/http/request.py b/django/http/request.py
index 42da121ae1..17771f7ef6 100644
--- a/django/http/request.py
+++ b/django/http/request.py
@@ -1,5 +1,6 @@
import copy
import re
+import warnings
from io import BytesIO
from itertools import chain
from urllib.parse import quote, urlencode, urljoin, urlsplit
@@ -12,6 +13,7 @@ from django.core.exceptions import (
from django.core.files import uploadhandler
from django.http.multipartparser import MultiPartParser, MultiPartParserError
from django.utils.datastructures import ImmutableList, MultiValueDict
+from django.utils.deprecation import RemovedInDjango30Warning
from django.utils.encoding import escape_uri_path, force_bytes, iri_to_uri
from django.utils.http import is_same_domain, limited_parse_qsl
@@ -328,14 +330,19 @@ class HttpRequest:
except IOError as e:
raise UnreadablePostError(*e.args) from e
- def xreadlines(self):
+ def __iter__(self):
while True:
buf = self.readline()
if not buf:
break
yield buf
- __iter__ = xreadlines
+ def xreadlines(self):
+ warnings.warn(
+ 'HttpRequest.xreadlines() is deprecated in favor of iterating the '
+ 'request.', RemovedInDjango30Warning, stacklevel=2,
+ )
+ yield from self
def readlines(self):
return list(iter(self))