Skip to content

Commit aaad3d8

Browse files
committed
Fix a Python 3 compatibility issue in trytls.runner
1 parent c350558 commit aaad3d8

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

runners/trytls/runner.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,20 @@ def run_one(args, host, port, cafile=None):
7878
raise ProcessFailed("failed to launch the stub", os.strerror(ose.errno))
7979

8080
out, _ = process.communicate()
81+
out = out.decode("ascii", "replace")
82+
8183
if process.returncode != 0:
8284
raise ProcessFailed("stub exited with return code {}".format(process.returncode), out)
8385

8486
out = out.rstrip()
8587
lines = out.splitlines()
8688
if lines:
8789
verdict = lines.pop()
88-
if verdict == b"ACCEPT":
90+
if verdict == "ACCEPT":
8991
return True, "".join(lines)
90-
elif verdict == b"REJECT":
92+
elif verdict == "REJECT":
9193
return False, "".join(lines)
92-
elif verdict == b"UNSUPPORTED":
94+
elif verdict == "UNSUPPORTED":
9395
raise Unsupported("".join(lines))
9496
raise UnexpectedOutput(out)
9597

@@ -138,10 +140,13 @@ def format(self, test, res):
138140
accept="accept" if test.accept else "reject"
139141
)
140142

141-
if res.reason.rstrip():
142-
template += reset + self.base + "\n" + indent("reason: " + self.reason + res.reason.rstrip(), by=6)
143-
if res.details.rstrip():
144-
template += reset + self.base + "\n" + indent("output: ", by=6) + self.details + indent(res.details.rstrip(), by=14, first_line=False)
143+
reason = res.reason.rstrip()
144+
if reason:
145+
template += reset + self.base + "\n" + indent("reason: " + self.reason + reason, by=6)
146+
147+
details = res.details.rstrip()
148+
if details:
149+
template += reset + self.base + "\n" + indent("output: ", by=6) + self.details + indent(details, by=14, first_line=False)
145150

146151
return template
147152

0 commit comments

Comments
 (0)