summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelie <elie>2013-12-01 21:18:58 +0000
committerelie <elie>2013-12-01 21:18:58 +0000
commit78ba77094a788190c3403201bf101f22297b9aba (patch)
tree2d8d56b3a3b32f01a98891c104e7bc77a86e1702
parent1b0729901cc034b95eed6225271155136d5d2f09 (diff)
downloadpyasn1-78ba77094a788190c3403201bf101f22297b9aba.tar.gz
AbstractConstructedAsn1Item.__repr__() fixed to include all class initializers
-rw-r--r--CHANGES2
-rw-r--r--pyasn1/type/base.py11
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):