From 042261266f5b901b2b0745fd108c9a92525e9087 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 6 Jan 2017 00:31:06 +0100 Subject: minor encoding fixes - native() -> always_str() The old function name does not make sense on Python 3 only. - Inline utility functions in message.py. --- pathod/log.py | 2 +- pathod/pathoc.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'pathod') diff --git a/pathod/log.py b/pathod/log.py index 4e5f355f..f7a7fc98 100644 --- a/pathod/log.py +++ b/pathod/log.py @@ -61,7 +61,7 @@ class LogCtx: for line in strutils.hexdump(data): self("\t%s %s %s" % line) else: - data = strutils.native( + data = strutils.always_str( strutils.escape_control_characters( data .decode("ascii", "replace") diff --git a/pathod/pathoc.py b/pathod/pathoc.py index 066c330c..3e804b63 100644 --- a/pathod/pathoc.py +++ b/pathod/pathoc.py @@ -44,7 +44,7 @@ class SSLInfo: def __str__(self): parts = [ - "Application Layer Protocol: %s" % strutils.native(self.alp, "utf8"), + "Application Layer Protocol: %s" % strutils.always_str(self.alp, "utf8"), "Cipher: %s, %s bit, %s" % self.cipher, "SSL certificate chain:" ] @@ -53,24 +53,24 @@ class SSLInfo: parts.append("\tSubject: ") for cn in i.get_subject().get_components(): parts.append("\t\t%s=%s" % ( - strutils.native(cn[0], "utf8"), - strutils.native(cn[1], "utf8")) + strutils.always_str(cn[0], "utf8"), + strutils.always_str(cn[1], "utf8")) ) parts.append("\tIssuer: ") for cn in i.get_issuer().get_components(): parts.append("\t\t%s=%s" % ( - strutils.native(cn[0], "utf8"), - strutils.native(cn[1], "utf8")) + strutils.always_str(cn[0], "utf8"), + strutils.always_str(cn[1], "utf8")) ) parts.extend( [ "\tVersion: %s" % i.get_version(), "\tValidity: %s - %s" % ( - strutils.native(i.get_notBefore(), "utf8"), - strutils.native(i.get_notAfter(), "utf8") + strutils.always_str(i.get_notBefore(), "utf8"), + strutils.always_str(i.get_notAfter(), "utf8") ), "\tSerial: %s" % i.get_serial_number(), - "\tAlgorithm: %s" % strutils.native(i.get_signature_algorithm(), "utf8") + "\tAlgorithm: %s" % strutils.always_str(i.get_signature_algorithm(), "utf8") ] ) pk = i.get_pubkey() @@ -82,7 +82,7 @@ class SSLInfo: parts.append("\tPubkey: %s bit %s" % (pk.bits(), t)) s = certs.SSLCert(i) if s.altnames: - parts.append("\tSANs: %s" % " ".join(strutils.native(n, "utf8") for n in s.altnames)) + parts.append("\tSANs: %s" % " ".join(strutils.always_str(n, "utf8") for n in s.altnames)) return "\n".join(parts) -- cgit v1.2.3