Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.6.x] Fixed #15625 -- Made message in MultiValueDictKeyError less v…

…erbose.

Thanks margieroginski for the suggestion.

Backport of 8931985 from master
  • Loading branch information...
commit 275497c5709792b47c71538a7e58bb40e8d8d3a9 1 parent 325b03e
Tim Graham authored September 16, 2013
2  django/utils/datastructures.py
@@ -298,7 +298,7 @@ def __getitem__(self, key):
298 298
         try:
299 299
             list_ = super(MultiValueDict, self).__getitem__(key)
300 300
         except KeyError:
301  
-            raise MultiValueDictKeyError("Key %r not found in %r" % (key, self))
  301
+            raise MultiValueDictKeyError(repr(key))
302 302
         try:
303 303
             return list_[-1]
304 304
         except IndexError:
6  tests/utils_tests/test_datastructures.py
@@ -234,11 +234,7 @@ def test_multivaluedict(self):
234 234
                           [('name', ['Adrian', 'Simon']),
235 235
                            ('position', ['Developer'])])
236 236
 
237  
-        # MultiValueDictKeyError: "Key 'lastname' not found in
238  
-        # <MultiValueDict: {'position': ['Developer'],
239  
-        #                   'name': ['Adrian', 'Simon']}>"
240  
-        six.assertRaisesRegex(self, MultiValueDictKeyError,
241  
-            r'"Key \'lastname\' not found in <MultiValueDict',
  237
+        six.assertRaisesRegex(self, MultiValueDictKeyError, 'lastname',
242 238
             d.__getitem__, 'lastname')
243 239
 
244 240
         self.assertEqual(d.get('lastname'), None)

0 notes on commit 275497c

Please sign in to comment.
Something went wrong with that request. Please try again.