diff options
author | elie <elie> | 2011-11-07 16:06:34 +0000 |
---|---|---|
committer | elie <elie> | 2011-11-07 16:06:34 +0000 |
commit | 108264527c2803a00e3821025151da1cc96bce76 (patch) | |
tree | 83f6370693dd8ca37d3044ec45d8cc01cffe537c | |
parent | 18304447e61e149245c200f3caa474c6652f6e13 (diff) | |
download | pyasn1-108264527c2803a00e3821025151da1cc96bce76.tar.gz |
fix to OctetString.__str__() workings of a non-initialized object
-rw-r--r-- | CHANGES | 5 | ||||
-rw-r--r-- | pyasn1/type/univ.py | 2 | ||||
-rw-r--r-- | test/type/univ.py | 10 |
3 files changed, 15 insertions, 2 deletions
@@ -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): |