Ticket #13572: querydict-copy-encoding-fix-and-tests.patch
File querydict-copy-encoding-fix-and-tests.patch, 1.8 KB (added by , 15 years ago) |
---|
-
django/http/__init__.py
177 177 super(QueryDict, self).__delitem__(key) 178 178 179 179 def __copy__(self): 180 result = self.__class__('', mutable=True )180 result = self.__class__('', mutable=True, encoding=self.encoding) 181 181 for key, value in dict.items(self): 182 182 dict.__setitem__(result, key, value) 183 183 return result 184 184 185 185 def __deepcopy__(self, memo): 186 186 import django.utils.copycompat as copy 187 result = self.__class__('', mutable=True )187 result = self.__class__('', mutable=True, encoding=self.encoding) 188 188 memo[id(self)] = result 189 189 for key, value in dict.items(self): 190 190 dict.__setitem__(result, copy.deepcopy(key, memo), copy.deepcopy(value, memo)) -
tests/regressiontests/httpwrappers/tests.py
392 392 [u'bar', u'\ufffd'] 393 393 394 394 395 ####################################### 396 # QueryDict with non-default encoding # 397 ####################################### 398 399 >>> q = QueryDict('sbb=one', encoding='rot_13') 400 >>> q.encoding 401 'rot_13' 402 403 >>> q.items() 404 [(u'foo', u'bar')] 405 406 >>> q.urlencode() 407 'sbb=one' 408 409 >>> q = q.copy() 410 >>> q.encoding 411 'rot_13' 412 413 >>> q.items() 414 [(u'foo', u'bar')] 415 416 >>> q.urlencode() 417 'sbb=one' 418 419 >>> from copy import copy 420 >>> copy(q).encoding 421 'rot_13' 422 423 >>> from copy import deepcopy 424 >>> deepcopy(q).encoding 425 'rot_13' 426 427 428 395 429 ######################## 396 430 # Pickling a QueryDict # 397 431 ########################