summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/fields.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py
index 9df8955392..134b63a625 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -503,6 +503,11 @@ class ImageField(FileField):
# but it must be called immediately after the constructor
trial_image = Image.open(file)
trial_image.verify()
+ except ImportError:
+ # Under PyPy, it is possible to import PIL. However, the underlying
+ # _imaging C module isn't available, so an ImportError will be
+ # raised. Catch and re-raise.
+ raise
except Exception: # Python Imaging Library doesn't recognize it as an image
raise ValidationError(self.error_messages['invalid_image'])
if hasattr(f, 'seek') and callable(f.seek):