mirror of
https://github.com/StevenBlack/hosts.git
synced 2026-07-01 02:36:52 +00:00
Update error handling in get_file_by_url
I don't believe the the .text could actually raise that exception. Oops.
This commit is contained in:
@@ -1495,16 +1495,8 @@ def get_file_by_url(url, params=None, **kwargs):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
req.encoding = req.apparent_encoding
|
req.encoding = req.apparent_encoding
|
||||||
|
res_text = "\n".join([domain_to_idna(line) for line in req.text.split("\n")])
|
||||||
try:
|
return res_text
|
||||||
res_text = req.text
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
print("Decoding error when retrieving data from {}".format(url))
|
|
||||||
return None
|
|
||||||
|
|
||||||
res = "\n".join([domain_to_idna(line) for line in res_text.split("\n")])
|
|
||||||
|
|
||||||
return res
|
|
||||||
|
|
||||||
|
|
||||||
def write_data(f, data):
|
def write_data(f, data):
|
||||||
|
|||||||
Reference in New Issue
Block a user