From 78ba77094a788190c3403201bf101f22297b9aba Mon Sep 17 00:00:00 2001 From: elie Date: Sun, 1 Dec 2013 21:18:58 +0000 Subject: AbstractConstructedAsn1Item.__repr__() fixed to include all class initializers --- CHANGES | 2 +- pyasn1/type/base.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index bab7936..a5f8267 100644 --- a/CHANGES +++ b/CHANGES @@ -16,7 +16,7 @@ Revision 0.1.8 - The base.NoValue() class instances now support __repr__() what makes possible to perform repr() on uninitialized pyasn1 types objects. - Fix to NamedType.__repr__() to work properly. -- Fixes to __repr__() implementation of many Scalar types to take into +- Fixes to __repr__() implementation of many built-in ASN.1 types to take into account all of their initializers such as tagSet, subtypeSpec etc. - String typed float initializer to REAL type now supported. - Float typed mantissa initializer to REAL type for base 2 added. diff --git a/pyasn1/type/base.py b/pyasn1/type/base.py index 19b037c..7d3445c 100644 --- a/pyasn1/type/base.py +++ b/pyasn1/type/base.py @@ -172,13 +172,20 @@ class AbstractConstructedAsn1Item(Asn1ItemBase): self._componentValuesSet = 0 def __repr__(self): - r = self.__class__.__name__ + '()' + r = [] + if self._componentType is not self.componentType: + r.append('componentType=%r' % (self._componentType,)) + if self._tagSet is not self.tagSet: + r.append('tagSet=%r' % (self._tagSet,)) + if self._subtypeSpec is not self.subtypeSpec: + r.append('subtypeSpec=%r' % (self._subtypeSpec,)) + r = '%s(%s)' % (self.__class__.__name__, ', '.join(r)) for idx in range(len(self._componentValues)): if self._componentValues[idx] is None: continue r = r + '.setComponentByPosition(%s, %r)' % ( idx, self._componentValues[idx] - ) + ) return r def __eq__(self, other): -- cgit v1.2.1