From 9e3e49ee709c45cde4e2bc1fd42923eff80019f1 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 15 Jul 2021 08:36:05 +0200 Subject: [PATCH] SysDNS: simplify encoding setup --- SysDNS/plugin.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/SysDNS/plugin.py b/SysDNS/plugin.py index 05d2b14..bfff032 100644 --- a/SysDNS/plugin.py +++ b/SysDNS/plugin.py @@ -71,18 +71,17 @@ class SysDNS(callbacks.Plugin): try: with open(os.devnull) as null: - inst = subprocess.Popen(args, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + inst = subprocess.Popen(args, encoding='utf-8', errors='replace', + stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=null) except OSError as e: irc.error('It seems the configured \'host\' command was ' 'not available (%s).' % e, Raise=True) result = inst.communicate() if result[1]: # stderr - irc.error(' '.join(result[1].decode('utf8').split())) + irc.error(' '.join(result[1].split())) if result[0]: # stdout - response = result[0].decode('utf8').splitlines() + response = result[0].splitlines() response = [l for l in response if l] irc.replies(response) elif not result[1]: