Changes between Initial Version and Version 3 of Ticket #29323


Ignore:
Timestamp:
Apr 16, 2018, 8:02:31 AM (7 years ago)
Author:
Thomas Riccardi
Comment:

OK.

I tested with python3 and it breaks too, but only because the code explicitly tries to generates an unicode string (bytes_to_text in appendlist).

I updated the description to also add the python3 test.

To support binary we would need to add an explicit option to get the bytes (maybe an encoding that asks to keep bytes?); not sure how to expose it in HTTPRequest.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #29323

    • Property Type UncategorizedBug
    • Property Summary HTTPRequest QueryDict wrongly decodes binary encoded values in python2HTTPRequest QueryDict wrongly decodes binary encoded values
  • Ticket #29323 – Description

    initial v3  
    2727
    2828
    29 I have not (yet) tested with python3.
     29In python 3 it fails too, but probably only because of the forced post-query-string-parser decoding into unicode string: to support binary values we don't want decoding at this point.
     30
     31A test for python3:
     32{{{#!python
     33    def test_binary_input(self):
     34        """
     35        QueryDicts must be able to handle binary.
     36        """
     37        q = QueryDict(b'foo=%00%7f%80%ff')
     38        self.assertListEqual(list(map(ord, q['foo'])), [0x00, 0x7F, 0x80, 0xFF])
     39}}}
     40{{{
     41AssertionError: Lists differ: [0, 127, 65533, 65533] != [0, 127, 128, 255]
     42
     43First differing element 2:
     4465533
     45128
     46
     47- [0, 127, 65533, 65533]
     48+ [0, 127, 128, 255]
     49}}}
Back to Top