Fixed #13572: copies of QueryDicts now have their encoding set correctly.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13314 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
8a10078a03
commit
3180f93236
|
@ -177,14 +177,14 @@ class QueryDict(MultiValueDict):
|
||||||
super(QueryDict, self).__delitem__(key)
|
super(QueryDict, self).__delitem__(key)
|
||||||
|
|
||||||
def __copy__(self):
|
def __copy__(self):
|
||||||
result = self.__class__('', mutable=True)
|
result = self.__class__('', mutable=True, encoding=self.encoding)
|
||||||
for key, value in dict.items(self):
|
for key, value in dict.items(self):
|
||||||
dict.__setitem__(result, key, value)
|
dict.__setitem__(result, key, value)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def __deepcopy__(self, memo):
|
def __deepcopy__(self, memo):
|
||||||
import django.utils.copycompat as copy
|
import django.utils.copycompat as copy
|
||||||
result = self.__class__('', mutable=True)
|
result = self.__class__('', mutable=True, encoding=self.encoding)
|
||||||
memo[id(self)] = result
|
memo[id(self)] = result
|
||||||
for key, value in dict.items(self):
|
for key, value in dict.items(self):
|
||||||
dict.__setitem__(result, copy.deepcopy(key, memo), copy.deepcopy(value, memo))
|
dict.__setitem__(result, copy.deepcopy(key, memo), copy.deepcopy(value, memo))
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import unittest
|
import copy
|
||||||
import pickle
|
import pickle
|
||||||
|
import unittest
|
||||||
from django.http import QueryDict, HttpResponse, CompatCookie, BadHeaderError
|
from django.http import QueryDict, HttpResponse, CompatCookie, BadHeaderError
|
||||||
|
|
||||||
class QueryDictTests(unittest.TestCase):
|
class QueryDictTests(unittest.TestCase):
|
||||||
|
@ -182,6 +183,19 @@ class QueryDictTests(unittest.TestCase):
|
||||||
x.update(y)
|
x.update(y)
|
||||||
self.assertEqual(x.getlist('a'), [u'1', u'2', u'3', u'4'])
|
self.assertEqual(x.getlist('a'), [u'1', u'2', u'3', u'4'])
|
||||||
|
|
||||||
|
def test_non_default_encoding(self):
|
||||||
|
"""#13572 - QueryDict with a non-default encoding"""
|
||||||
|
q = QueryDict('sbb=one', encoding='rot_13')
|
||||||
|
self.assertEqual(q.encoding , 'rot_13' )
|
||||||
|
self.assertEqual(q.items() , [(u'foo', u'bar')] )
|
||||||
|
self.assertEqual(q.urlencode() , 'sbb=one' )
|
||||||
|
q = q.copy()
|
||||||
|
self.assertEqual(q.encoding , 'rot_13' )
|
||||||
|
self.assertEqual(q.items() , [(u'foo', u'bar')] )
|
||||||
|
self.assertEqual(q.urlencode() , 'sbb=one' )
|
||||||
|
self.assertEqual(copy.copy(q).encoding , 'rot_13' )
|
||||||
|
self.assertEqual(copy.deepcopy(q).encoding , 'rot_13')
|
||||||
|
|
||||||
class HttpResponseTests(unittest.TestCase):
|
class HttpResponseTests(unittest.TestCase):
|
||||||
def test_unicode_headers(self):
|
def test_unicode_headers(self):
|
||||||
r = HttpResponse()
|
r = HttpResponse()
|
||||||
|
|
Loading…
Reference in New Issue