mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Fixed #7233 -- Ensured that QueryDict classes are always unpicklable. This
problem only arose on some systems, since it depends upon the order in which the attributes are pickled. Makes reliable testing kind of tricky. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8460 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
		| @@ -392,17 +392,26 @@ u'\ufffd' | ||||
| [u'bar', u'\ufffd'] | ||||
|  | ||||
|  | ||||
| ######################################  | ||||
| # HttpResponse with Unicode headers  #  | ||||
| ######################################  | ||||
|   | ||||
| >>> r = HttpResponse()  | ||||
|   | ||||
| ######################## | ||||
| # Pickling a QueryDict # | ||||
| ######################## | ||||
| >>> import pickle | ||||
| >>> q = QueryDict('a=b&c=d') | ||||
| >>> q1 = pickle.loads(pickle.dumps(q)) | ||||
| >>> q == q1 | ||||
| True | ||||
|  | ||||
| ###################################### | ||||
| # HttpResponse with Unicode headers  # | ||||
| ###################################### | ||||
|  | ||||
| >>> r = HttpResponse() | ||||
|  | ||||
| If we insert a unicode value it will be converted to an ascii | ||||
| string. This makes sure we comply with the HTTP specifications. | ||||
|   | ||||
| >>> r['value'] = u'test value'  | ||||
| >>> isinstance(r['value'], str)  | ||||
|  | ||||
| >>> r['value'] = u'test value' | ||||
| >>> isinstance(r['value'], str) | ||||
| True | ||||
|  | ||||
| An error is raised When a unicode object with non-ascii is assigned. | ||||
| @@ -411,10 +420,10 @@ An error is raised When a unicode object with non-ascii is assigned. | ||||
| Traceback (most recent call last): | ||||
| ... | ||||
| UnicodeEncodeError: ..., HTTP response headers must be in US-ASCII format | ||||
|   | ||||
| The response also converts unicode keys to strings.  | ||||
|   | ||||
| >>> r[u'test'] = 'testing key'  | ||||
|  | ||||
| The response also converts unicode keys to strings. | ||||
|  | ||||
| >>> r[u'test'] = 'testing key' | ||||
| >>> l = list(r.items()) | ||||
| >>> l.sort() | ||||
| >>> l[1] | ||||
| @@ -426,7 +435,7 @@ It will also raise errors for keys with non-ascii data. | ||||
| Traceback (most recent call last): | ||||
| ... | ||||
| UnicodeEncodeError: ..., HTTP response headers must be in US-ASCII format | ||||
|   | ||||
|  | ||||
| """ | ||||
|  | ||||
| from django.http import QueryDict, HttpResponse | ||||
|   | ||||
		Reference in New Issue
	
	Block a user