diff options
| author | Claude Paroz <claude@2xlibre.net> | 2017-01-07 20:13:29 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2017-01-22 20:08:04 +0100 |
| commit | 6e55e1d88a5c4453e25f0caf7ffb68973de5c0ba (patch) | |
| tree | 4084a5083b9e44ea90e9a119581d09efc9d41228 /django/http | |
| parent | d170c63351944fd91b2206d10f89e7ff75b53b76 (diff) | |
Refs #23919 -- Replaced six.reraise by raise
Diffstat (limited to 'django/http')
| -rw-r--r-- | django/http/multipartparser.py | 7 | ||||
| -rw-r--r-- | django/http/request.py | 8 |
2 files changed, 5 insertions, 10 deletions
diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py index ff7e36e321..6a0ff2c86c 100644 --- a/django/http/multipartparser.py +++ b/django/http/multipartparser.py @@ -7,7 +7,6 @@ file upload handlers for processing. import base64 import binascii import cgi -import sys from urllib.parse import unquote from django.conf import settings @@ -17,7 +16,6 @@ from django.core.exceptions import ( from django.core.files.uploadhandler import ( SkipFile, StopFutureHandlers, StopUpload, ) -from django.utils import six from django.utils.datastructures import MultiValueDict from django.utils.encoding import force_text from django.utils.text import unescape_entities @@ -247,10 +245,9 @@ class MultiPartParser: try: chunk = base64.b64decode(stripped_chunk) - except Exception as e: + except Exception as exc: # Since this is only a chunk, any error is an unfixable error. - msg = "Could not decode base64 data: %r" % e - six.reraise(MultiPartParserError, MultiPartParserError(msg), sys.exc_info()[2]) + raise MultiPartParserError("Could not decode base64 data.") from exc for i, handler in enumerate(handlers): chunk_length = len(chunk) diff --git a/django/http/request.py b/django/http/request.py index 554e05217d..bae0b6f3ec 100644 --- a/django/http/request.py +++ b/django/http/request.py @@ -1,6 +1,5 @@ import copy import re -import sys from io import BytesIO from itertools import chain from urllib.parse import quote, urlencode, urljoin, urlsplit @@ -12,7 +11,6 @@ from django.core.exceptions import ( ) from django.core.files import uploadhandler from django.http.multipartparser import MultiPartParser, MultiPartParserError -from django.utils import six from django.utils.datastructures import ImmutableList, MultiValueDict from django.utils.encoding import escape_uri_path, force_bytes, iri_to_uri from django.utils.http import is_same_domain, limited_parse_qsl @@ -263,7 +261,7 @@ class HttpRequest: try: self._body = self.read() except IOError as e: - six.reraise(UnreadablePostError, UnreadablePostError(*e.args), sys.exc_info()[2]) + raise UnreadablePostError(*e.args) from e self._stream = BytesIO(self._body) return self._body @@ -322,14 +320,14 @@ class HttpRequest: try: return self._stream.read(*args, **kwargs) except IOError as e: - six.reraise(UnreadablePostError, UnreadablePostError(*e.args), sys.exc_info()[2]) + 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: - six.reraise(UnreadablePostError, UnreadablePostError(*e.args), sys.exc_info()[2]) + raise UnreadablePostError(*e.args) from e def xreadlines(self): while True: |
