Fixed #22996 -- Prevented crash with unencoded query string (Python 3)

Thanks Jorge Carleitao for the report and Aymeric Augustin for the
review.
could we comment here why we are using iso-8859-1?