      if six.PY2:
          def test_invalid_input_encoding(self):
              """
              QueryDicts must be able to handle invalid input encoding (in this
              case, bad UTF-8 encoding).
  
              This test doesn't apply under Python 3 because the URL is a string
              and not a bytestring.
              """
              q = QueryDict(str(b'foo=bar&foo=\xff'))
 
</s> remove             self.assertEqual(q['foo'], '\ufffd')
            self.assertEqual(q.getlist('foo'), ['bar', '\ufffd'])
 </s> add             self.assertEqual(q['foo'], '\xff')
            self.assertEqual(q.getlist('foo'), ['bar', '\xff']) </s> remove                                 force_text(value, encoding, errors='replace'))
 </s> add                                 value) </s> remove                 # query_string contains URL-encoded data, a subset of ASCII.
                query_string = query_string.decode()
 </s> add                 # 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')
            case, bad UTF-8 encoding), falling back to ISO-8859-1 decoding.
      if six.PY2:
          def test_invalid_input_encoding(self):
              """
              QueryDicts must be able to handle invalid input encoding (in this
            case, bad UTF-8 encoding), falling back to ISO-8859-1 decoding.
  
              This test doesn't apply under Python 3 because the URL is a string
              and not a bytestring.
              """
              q = QueryDict(str(b'foo=bar&foo=\xff'))
keep keep keep keep replace keep keep keep keep keep
 Fixed #22996 -- Prevented crash with unencoded query string

Thanks Jorge Carleitao for the report and Aymeric Augustin, Tim Graham
for the reviews. 
tests/httpwrappers/tests.py