diff options
Diffstat (limited to 'pyasn1/type/base.py')
-rw-r--r-- | pyasn1/type/base.py | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/pyasn1/type/base.py b/pyasn1/type/base.py index 1fd69f9..834b76e 100644 --- a/pyasn1/type/base.py +++ b/pyasn1/type/base.py @@ -498,17 +498,39 @@ class ConstructedAsn1Type(Asn1Type): strictConstraints = False componentType = None - sizeSpec = None + + # backward compatibility, unused + sizeSpec = constraint.ConstraintsIntersection() def __init__(self, **kwargs): readOnly = { 'componentType': self.componentType, + # backward compatibility, unused 'sizeSpec': self.sizeSpec } + + # backward compatibility: preserve legacy sizeSpec support + kwargs = self._moveSizeSpec(**kwargs) + readOnly.update(kwargs) Asn1Type.__init__(self, **readOnly) + def _moveSizeSpec(self, **kwargs): + # backward compatibility, unused + sizeSpec = kwargs.pop('sizeSpec', self.sizeSpec) + if sizeSpec: + subtypeSpec = kwargs.pop('subtypeSpec', self.subtypeSpec) + if subtypeSpec: + subtypeSpec = sizeSpec + + else: + subtypeSpec += sizeSpec + + kwargs['subtypeSpec'] = subtypeSpec + + return kwargs + def __repr__(self): representation = '%s %s object' % ( self.__class__.__name__, self.isValue and 'value' or 'schema' @@ -667,7 +689,7 @@ class ConstructedAsn1Type(Asn1Type): :py:class:`~pyasn1.error.PyAsn1tError` on any inconsistencies found """ try: - self.sizeSpec(self) + self.subtypeSpec(self) except error.PyAsn1Error: exc = sys.exc_info()[1] @@ -694,9 +716,10 @@ class ConstructedAsn1Type(Asn1Type): def getComponentType(self): return self.componentType + # backward compatibility, unused def verifySizeSpec(self): - self.sizeSpec(self) + self.subtypeSpec(self) -# Backward compatibility + # Backward compatibility AbstractConstructedAsn1Item = ConstructedAsn1Type |