Author: jacob
Date: 2010-05-28 11:39:52 -0500 (Fri, 28 May 2010)
New Revision: 13314
Modified:
django/trunk/django/http/__init__.py
django/trunk/tests/regressiontests/httpwrappers/tests.py
Log:
Fixed #13572: copies of QueryDicts now have their encoding set correctly.
Modified: django/trunk/django/http/__init__.py
===================================================================
--- django/trunk/django/http/__init__.py 2010-05-28 16:27:09 UTC (rev
13313)
+++ django/trunk/django/http/__init__.py 2010-05-28 16:39:52 UTC (rev
13314)
@@ -177,14 +177,14 @@
super(QueryDict, self).__delitem__(key)
def __copy__(self):
- result = self.__class__('', mutable=True)
+ result = self.__class__('', mutable=True, encoding=self.encoding)
for key, value in dict.items(self):
dict.__setitem__(result, key, value)
return result
def __deepcopy__(self, memo):
import django.utils.copycompat as copy
- result = self.__class__('', mutable=True)
+ result = self.__class__('', mutable=True, encoding=self.encoding)
memo[id(self)] = result
for key, value in dict.items(self):
dict.__setitem__(result, copy.deepcopy(key, memo),
copy.deepcopy(value, memo))
Modified: django/trunk/tests/regressiontests/httpwrappers/tests.py
===================================================================
--- django/trunk/tests/regressiontests/httpwrappers/tests.py 2010-05-28
16:27:09 UTC (rev 13313)
+++ django/trunk/tests/regressiontests/httpwrappers/tests.py 2010-05-28
16:39:52 UTC (rev 13314)
@@ -1,5 +1,6 @@
+import copy
+import pickle
import unittest
-import pickle
from django.http import QueryDict, HttpResponse, CompatCookie, BadHeaderError
class QueryDictTests(unittest.TestCase):
@@ -182,6 +183,19 @@
x.update(y)
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):
def test_unicode_headers(self):
r = HttpResponse()
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.