Hi all, Why is it so that QueryDict for PY3 handles input query string different from PY2 (part of __init__ of QueryDict from Django 1.11.5):
if six.PY3: if isinstance(query_string, bytes): # query_string normally contains URL-encoded data, a subset of ASCII. try: query_string = query_string.decode(encoding) except UnicodeDecodeError: # ... but some user agents are misbehaving :-( query_string = query_string.decode('iso-8859-1') for key, value in limited_parse_qsl(query_string, **parse_qsl_kwargs): self.appendlist(key, value) else: for key, value in limited_parse_qsl(query_string, **parse_qsl_kwargs): try: value = value.decode(encoding) except UnicodeDecodeError: value = value.decode('iso-8859-1') self.appendlist(force_text(key, encoding, errors='replace'), value) Firstly, for PY3 decoding is done only once, for entire query string, while for PY2 query is parsed first, and then each value is decoded separately. Secondly, for PY3 query_string is being decoded only if it is of bytes type. Why there is no such check for PY2? Why not to decode only if it's not unicode? With such implementation it is not possible to pass unicode object that contains non-ascii characters to QueryDict. Can somebody give me a hint on why things wre done in this way? Thanks, Alexey. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f7e3ea04-b2c9-4baa-bb50-d56768b9b91f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.