diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py index c6a008ef5c..4aa99175be 100644 --- a/django/http/multipartparser.py +++ b/django/http/multipartparser.py @@ -163,7 +163,7 @@ class MultiPartParser: # Create the data structures to be used later. self._post = QueryDict(mutable=True) - self._files = MultiValueDict(mutable=True) + self._files = MultiValueDict() # Instantiate the parser and stream: stream = LazyStream(ChunkIter(self._input_data, self._chunk_size)) diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index 5de3f8b8c3..990ad71b2d 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -69,9 +69,11 @@ class MultiValueDict(dict): single name-value pairs. """ + _mutable = True + def __init__(self, key_to_list_mapping=(), mutable=True): - self._mutable = mutable super().__init__(key_to_list_mapping) + self._mutable = mutable def __repr__(self): return "<%s: %s>" % (self.__class__.__name__, super().__repr__()) @@ -117,7 +119,7 @@ class MultiValueDict(dict): self.__dict__.update(obj_dict) def _assert_mutable(self): - if hasattr(self, '_mutable') and not self._mutable: + if not self._mutable: raise AttributeError("This MultiValueDict instance is immutable") def get(self, key, default=None):