mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Refs #23919 -- Replaced six.reraise by raise
This commit is contained in:
@@ -7,7 +7,6 @@ import datetime
|
||||
import itertools
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import uuid
|
||||
from decimal import Decimal, DecimalException
|
||||
from io import BytesIO
|
||||
@@ -26,7 +25,7 @@ from django.forms.widgets import (
|
||||
SplitDateTimeWidget, SplitHiddenDateTimeWidget, TextInput, TimeInput,
|
||||
URLInput,
|
||||
)
|
||||
from django.utils import formats, six
|
||||
from django.utils import formats
|
||||
from django.utils.dateparse import parse_duration
|
||||
from django.utils.duration import duration_string
|
||||
from django.utils.encoding import force_text
|
||||
@@ -650,12 +649,12 @@ class ImageField(FileField):
|
||||
# Pillow doesn't detect the MIME type of all formats. In those
|
||||
# cases, content_type will be None.
|
||||
f.content_type = Image.MIME.get(image.format)
|
||||
except Exception:
|
||||
except Exception as exc:
|
||||
# Pillow doesn't recognize it as an image.
|
||||
six.reraise(ValidationError, ValidationError(
|
||||
raise ValidationError(
|
||||
self.error_messages['invalid_image'],
|
||||
code='invalid_image',
|
||||
), sys.exc_info()[2])
|
||||
) from exc
|
||||
if hasattr(f, 'seek') and callable(f.seek):
|
||||
f.seek(0)
|
||||
return f
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import json
|
||||
import sys
|
||||
from collections import UserList
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError # backwards compatibility
|
||||
from django.utils import six, timezone
|
||||
from django.utils import timezone
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.html import escape, format_html, format_html_join, html_safe
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
@@ -156,18 +155,14 @@ def from_current_timezone(value):
|
||||
current_timezone = timezone.get_current_timezone()
|
||||
try:
|
||||
return timezone.make_aware(value, current_timezone)
|
||||
except Exception:
|
||||
message = _(
|
||||
'%(datetime)s couldn\'t be interpreted '
|
||||
'in time zone %(current_timezone)s; it '
|
||||
'may be ambiguous or it may not exist.'
|
||||
)
|
||||
params = {'datetime': value, 'current_timezone': current_timezone}
|
||||
six.reraise(ValidationError, ValidationError(
|
||||
message,
|
||||
except Exception as exc:
|
||||
raise ValidationError(
|
||||
_('%(datetime)s couldn\'t be interpreted '
|
||||
'in time zone %(current_timezone)s; it '
|
||||
'may be ambiguous or it may not exist.'),
|
||||
code='ambiguous_timezone',
|
||||
params=params,
|
||||
), sys.exc_info()[2])
|
||||
params={'datetime': value, 'current_timezone': current_timezone}
|
||||
) from exc
|
||||
return value
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user