From 6fe9c45b725cd21eacbb50263bd3449e1a3edf17 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Thu, 27 Dec 2018 11:19:55 -0500 Subject: Fixed #30024 -- Made urlencode() and Client raise TypeError when None is passed as data. --- django/test/client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'django/test') diff --git a/django/test/client.py b/django/test/client.py index d14ba43792..07641b7e65 100644 --- a/django/test/client.py +++ b/django/test/client.py @@ -192,7 +192,12 @@ def encode_multipart(boundary, data): # file, or a *list* of form values and/or files. Remember that HTTP field # names can be duplicated! for (key, value) in data.items(): - if is_file(value): + if value is None: + raise TypeError( + 'Cannot encode None as POST data. Did you mean to pass an ' + 'empty string or omit the value?' + ) + elif is_file(value): lines.extend(encode_file(boundary, key, value)) elif not isinstance(value, str) and is_iterable(value): for item in value: -- cgit v1.3