From: Jeremy Stanley Date: Sun, 31 May 2020 00:17:36 +0000 (+0000) Subject: Decode retrieved files as UTF-8 even on Python 2 X-Git-Tag: 2.4~6 X-Git-Url: https://yuggoth.org/gitweb?a=commitdiff_plain;h=5515f756d42c1fbb00f506cf30474143061863c6;p=weather.git 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. --- 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: