summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelie <elie>2015-01-01 12:27:49 +0000
committerelie <elie>2015-01-01 12:27:49 +0000
commit164a2773c09b202a9a4257571df966dfaa9c3c92 (patch)
tree8cc65c01d71975154a7086bcb566539d2348f129
parent61d9975ab596676eadb600f4d50a3cd72ca34c57 (diff)
downloadpyasn1-164a2773c09b202a9a4257571df966dfaa9c3c92.tar.gz
OctetString.prettyOut non-printables detection improved
-rw-r--r--pyasn1/type/univ.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/pyasn1/type/univ.py b/pyasn1/type/univ.py
index d623c7f..fa992ff 100644
--- a/pyasn1/type/univ.py
+++ b/pyasn1/type/univ.py
@@ -402,13 +402,13 @@ class OctetString(base.AbstractSimpleAsn1Item):
def prettyOut(self, value):
if sys.version_info[0] <= 2:
- numbers = tuple([ ord(x) for x in value ])
+ numbers = tuple(( ord(x) for x in value ))
else:
numbers = tuple(value)
- if [ x for x in numbers if x < 32 or x > 126 ]:
- return '0x' + ''.join([ '%.2x' % x for x in numbers ])
- else:
+ if all(x < 32 or x > 126 for x in numbers):
return str(value)
+ else:
+ return '0x' + ''.join(( '%.2x' % x for x in numbers ))
def __repr__(self):
r = []