From 6f48cea0a6163485b03481d20f6aefd925e8cbe9 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 18 Feb 2019 16:36:59 +1100 Subject: [PATCH] explicitly convert byte to string (cherry picked from commit ec3d830bc50e43858c7982df9b9db95aa8cffca0) --- bin/python/isc/checkds.py.in | 10 +++++++++- bin/python/isc/keyzone.py.in | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/python/isc/checkds.py.in b/bin/python/isc/checkds.py.in index 5669e6879d..9d6429c0b6 100644 --- a/bin/python/isc/checkds.py.in +++ b/bin/python/isc/checkds.py.in @@ -37,7 +37,11 @@ class SECRR: if not rrtext: raise Exception - fields = rrtext.decode('ascii').split() + # 'str' does not have decode method in python3 + if type(rrtext) is not str: + fields = rrtext.decode('ascii').split() + else: + fields = rrtext.split() if len(fields) < 7: raise Exception @@ -99,6 +103,8 @@ def check(zone, args, masterfile=None, lookaside=None): fp, _ = Popen(cmd, stdout=PIPE).communicate() for line in fp.splitlines(): + if type(line) is not str: + line = line.decode('ascii') rrlist.append(SECRR(line, lookaside)) rrlist = sorted(rrlist, key=lambda rr: (rr.keyid, rr.keyalg, rr.hashalg)) @@ -120,6 +126,8 @@ def check(zone, args, masterfile=None, lookaside=None): fp, _ = Popen(cmd, stdin=PIPE, stdout=PIPE).communicate(intods) for line in fp.splitlines(): + if type(line) is not str: + line = line.decode('ascii') klist.append(SECRR(line, lookaside)) if len(klist) < 1: diff --git a/bin/python/isc/keyzone.py.in b/bin/python/isc/keyzone.py.in index 2451d439e4..bc8c51d72f 100644 --- a/bin/python/isc/keyzone.py.in +++ b/bin/python/isc/keyzone.py.in @@ -43,6 +43,8 @@ class keyzone: fp, _ = Popen([czpath, "-o", "-", name, filename], stdout=PIPE, stderr=PIPE).communicate() for line in fp.splitlines(): + if type(line) is not str: + line = line.decode('ascii') if re.search('^[:space:]*;', line): continue fields = line.split()