diff --git a/django/forms/forms.py b/django/forms/forms.py
index ef9d657..775480f 100644
a
|
b
|
Form classes
|
4 | 4 | |
5 | 5 | from copy import deepcopy |
6 | 6 | |
7 | | from django.utils.datastructures import SortedDict |
| 7 | from django.utils.datastructures import SortedDict, MergeDict |
8 | 8 | from django.utils.html import conditional_escape |
9 | 9 | from django.utils.encoding import StrAndUnicode, smart_unicode, force_unicode |
10 | 10 | from django.utils.safestring import mark_safe |
… |
… |
class BaseForm(StrAndUnicode):
|
72 | 72 | initial=None, error_class=ErrorList, label_suffix=':', |
73 | 73 | empty_permitted=False): |
74 | 74 | self.is_bound = data is not None or files is not None |
| 75 | |
| 76 | if data <> None and not isinstance(data, (dict, MergeDict)): |
| 77 | raise TypeError('data parameter must be of type dict not of type %s' % type(data)) |
| 78 | |
| 79 | if files <> None and not isinstance(files, (dict, MergeDict)): |
| 80 | raise TypeError('files parameter must be of type dict not of type %s' % type(files)) |
| 81 | |
75 | 82 | self.data = data or {} |
76 | 83 | self.files = files or {} |
77 | 84 | self.auto_id = auto_id |
diff --git a/tests/regressiontests/forms/forms.py b/tests/regressiontests/forms/forms.py
index 642cd20..876cdca 100644
a
|
b
|
u'Lennon'
|
189 | 189 | >>> p.cleaned_data['birthday'] |
190 | 190 | datetime.date(1940, 10, 9) |
191 | 191 | |
| 192 | passing something other than a dict into __init__ will raise a TypeError |
| 193 | >>> p = Person('a string') |
| 194 | Traceback (most recent call last): |
| 195 | ... |
| 196 | TypeError: data parameter must be of type dict not of type <type 'str'> |
| 197 | |
| 198 | this is also true for the files parameter of __init__ |
| 199 | >>> p = Person(data, files='another string') |
| 200 | Traceback (most recent call last): |
| 201 | ... |
| 202 | TypeError: files parameter must be of type dict not of type <type 'str'> |
192 | 203 | |
193 | 204 | cleaned_data will include a key and value for *all* fields defined in the Form, |
194 | 205 | even if the Form's data didn't include a value for fields that are not |