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

Thanks Jorge Carleitao for the report and Aymeric Augustin for the
review.
Since 'iso-8859-1' is being used in the line above also, I wonder if it is not better have a variable on top like `FALLBACK_ENCODING = 'iso-8859-1'`