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

Thanks Jorge Carleitao for the report and Aymeric Augustin for the
review.
fallsback