From 5515f756d42c1fbb00f506cf30474143061863c6 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Sun, 31 May 2020 00:17:36 +0000 Subject: [PATCH] Decode retrieved files as UTF-8 even on Python 2 Python 2.7 is likely the only Python 2 anyone is using any longer (even that's well past EOL upstream now), and reasonably recent versions of 2.7 it need the same decode hack as Python 3 anyway when dealing with some retrieved content. Just get rid of the version detection and do it under any version. --- weather.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/weather.py b/weather.py index 369ce99..fa94727 100644 --- a/weather.py +++ b/weather.py @@ -222,8 +222,7 @@ def get_uri( dcache_fd.close() else: try: - if pyversion("3"): data = urlopen(uri).read().decode("utf-8") - else: data = urlopen(uri).read() + data = urlopen(uri).read().decode("utf-8") except URLError: if ignore_fail: return "" else: -- 2.11.0