summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelie <elie>2011-11-07 16:06:34 +0000
committerelie <elie>2011-11-07 16:06:34 +0000
commit108264527c2803a00e3821025151da1cc96bce76 (patch)
tree83f6370693dd8ca37d3044ec45d8cc01cffe537c
parent18304447e61e149245c200f3caa474c6652f6e13 (diff)
downloadpyasn1-108264527c2803a00e3821025151da1cc96bce76.tar.gz
fix to OctetString.__str__() workings of a non-initialized object
-rw-r--r--CHANGES5
-rw-r--r--pyasn1/type/univ.py2
-rw-r--r--test/type/univ.py10
3 files changed, 15 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 5262f07..ab18eba 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+Revision 0.1.2
+--------------
+
+- Fix to OctetString.__str__() workings of a non-initialized object.
+
Revision 0.1.1
--------------
diff --git a/pyasn1/type/univ.py b/pyasn1/type/univ.py
index e1f4c35..1572e14 100644
--- a/pyasn1/type/univ.py
+++ b/pyasn1/type/univ.py
@@ -383,7 +383,7 @@ class OctetString(base.AbstractSimpleAsn1Item):
return self.__class__.__name__ + '(' + self.prettyOut(self._value) + ')'
if sys.version_info[0] <= 2:
- def __str__(self): return self._value
+ def __str__(self): return str(self._value)
def __unicode__(self):
return self._value.decode(self._encoding, 'ignore')
def asOctets(self): return self._value
diff --git a/test/type/univ.py b/test/type/univ.py
index 10d25ed..9f4ac68 100644
--- a/test/type/univ.py
+++ b/test/type/univ.py
@@ -115,7 +115,15 @@ class OctetStringTestCase(unittest.TestCase):
assert univ.OctetString('abcd').asOctets() == str2octs('abcd'), 'testAsOctets() fails'
def testAsInts(self):
assert univ.OctetString('abcd').asNumbers() == (97, 98, 99, 100), 'testAsNumbers() fails'
-
+
+ def testEmpty(self):
+ try:
+ str(univ.OctetString())
+ except PyAsn1Error:
+ pass
+ else:
+ assert 0, 'empty OctetString() not reported'
+
def testAdd(self):
assert univ.OctetString('') + 'q' == str2octs('q'), '__add__() fails'
def testRadd(self):