summaryrefslogtreecommitdiff
path: root/django/http
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2019-01-28 07:01:35 -0800
committerTim Graham <timograham@gmail.com>2019-01-28 11:15:06 -0500
commit7785e03ba89aafbd949191f126361fb9103cb980 (patch)
tree5776f7063604285445cfcebf6efb42fd5d063f60 /django/http
parent7444f3252757ed4384623e5afd7dcfeef3e0c74e (diff)
Fixed #30137 -- Replaced OSError aliases with the canonical OSError.
Used more specific errors (e.g. FileExistsError) as appropriate.
Diffstat (limited to 'django/http')
-rw-r--r--django/http/request.py8
-rw-r--r--django/http/response.py6
2 files changed, 7 insertions, 7 deletions
diff --git a/django/http/request.py b/django/http/request.py
index f1c232d89a..51d0a8dfc3 100644
--- a/django/http/request.py
+++ b/django/http/request.py
@@ -22,7 +22,7 @@ RAISE_ERROR = object()
host_validation_re = re.compile(r"^([a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9\.:]+\])(:\d+)?$")
-class UnreadablePostError(IOError):
+class UnreadablePostError(OSError):
pass
@@ -284,7 +284,7 @@ class HttpRequest:
try:
self._body = self.read()
- except IOError as e:
+ except OSError as e:
raise UnreadablePostError(*e.args) from e
self._stream = BytesIO(self._body)
return self._body
@@ -339,14 +339,14 @@ class HttpRequest:
self._read_started = True
try:
return self._stream.read(*args, **kwargs)
- except IOError as e:
+ except OSError as e:
raise UnreadablePostError(*e.args) from e
def readline(self, *args, **kwargs):
self._read_started = True
try:
return self._stream.readline(*args, **kwargs)
- except IOError as e:
+ except OSError as e:
raise UnreadablePostError(*e.args) from e
def __iter__(self):
diff --git a/django/http/response.py b/django/http/response.py
index 5a640a51cf..6a84e193ba 100644
--- a/django/http/response.py
+++ b/django/http/response.py
@@ -251,13 +251,13 @@ class HttpResponseBase:
signals.request_finished.send(sender=self._handler_class)
def write(self, content):
- raise IOError("This %s instance is not writable" % self.__class__.__name__)
+ raise OSError('This %s instance is not writable' % self.__class__.__name__)
def flush(self):
pass
def tell(self):
- raise IOError("This %s instance cannot tell its position" % self.__class__.__name__)
+ raise OSError('This %s instance cannot tell its position' % self.__class__.__name__)
# These methods partially implement a stream-like object interface.
# See https://docs.python.org/library/io.html#io.IOBase
@@ -272,7 +272,7 @@ class HttpResponseBase:
return False
def writelines(self, lines):
- raise IOError("This %s instance is not writable" % self.__class__.__name__)
+ raise OSError('This %s instance is not writable' % self.__class__.__name__)
class HttpResponse(HttpResponseBase):