1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

add _mutable class attribute to MultiValueDict, like QueryDict

This commit is contained in:
Ben Cail 2024-03-18 15:02:59 -04:00
parent 3e84dfbd24
commit 5aafc222ad
2 changed files with 5 additions and 3 deletions

View File

@ -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))

View File

@ -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):