From dbcd2fe985498889e1206f54c196f00879e79dae Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Thu, 1 Jun 2006 20:47:34 +0000 Subject: Fixed #2045 - TypeError thrown if a form does not have the correct enctype for uploading files. It throws a ValidationError now, as it should. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3048 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/forms/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'django/forms') diff --git a/django/forms/__init__.py b/django/forms/__init__.py index 52092aff7b..b67e1d0f84 100644 --- a/django/forms/__init__.py +++ b/django/forms/__init__.py @@ -641,7 +641,11 @@ class FileUploadField(FormField): self.validator_list = [self.isNonEmptyFile] + validator_list def isNonEmptyFile(self, field_data, all_data): - if not field_data['content']: + try: + content = field_data['content'] + except TypeError: + raise validators.CriticalValidationError, gettext("No file was submitted. Check the encoding type on the form.") + if not content: raise validators.CriticalValidationError, gettext("The submitted file is empty.") def render(self, data): -- cgit v1.3