added code to Utils.get_url to prevent non-iso-latin-1 urls being attempted. I need to put in a better fix than this at some point.

This commit is contained in:
jesopo 2016-03-29 21:05:07 +01:00
parent 57a0e2f10f
commit 076552c013
No known key found for this signature in database
GPG key ID: 0BBDEB2AEFCFFCB3

View file

@ -37,6 +37,12 @@ def get_url(url, **kwargs):
if post_params:
post_params = urllib.parse.urlencode(post_params).encode("utf8")
url = "%s%s" % (url, get_params)
try:
url.encode("latin-1")
except UnicodeEncodeError:
if kwargs.get("code"):
return 0, False
return False
request = urllib.request.Request(url, post_params)
request.add_header("Accept-Language", "en-US")