mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fixed #27583 -- Fixed MultiValueDict.getlist() crash when values for key is None.
Restored the behavior before 727d7ce6cb
.
This commit is contained in:
parent
4de8aaf7ff
commit
8e3a72f4fb
@ -146,7 +146,7 @@ class MultiValueDict(dict):
|
|||||||
return default
|
return default
|
||||||
else:
|
else:
|
||||||
if force_list:
|
if force_list:
|
||||||
values = list(values)
|
values = list(values) if values is not None else None
|
||||||
return values
|
return values
|
||||||
|
|
||||||
def getlist(self, key, default=None):
|
def getlist(self, key, default=None):
|
||||||
|
@ -119,6 +119,11 @@ class MultiValueDictTests(SimpleTestCase):
|
|||||||
values = x.getlist('b', default=MISSING)
|
values = x.getlist('b', default=MISSING)
|
||||||
self.assertIs(values, MISSING)
|
self.assertIs(values, MISSING)
|
||||||
|
|
||||||
|
def test_getlist_none_empty_values(self):
|
||||||
|
x = MultiValueDict({'a': None, 'b': []})
|
||||||
|
self.assertIsNone(x.getlist('a'))
|
||||||
|
self.assertEqual(x.getlist('b'), [])
|
||||||
|
|
||||||
|
|
||||||
class ImmutableListTests(SimpleTestCase):
|
class ImmutableListTests(SimpleTestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user