diff options
-rw-r--r-- | CHANGES.rst | 2 | ||||
-rw-r--r-- | pyasn1/type/namedtype.py | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index d43c0d0..943dd5b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,8 @@ Revision 0.3.3, released XX-08-2017 - Improved ASN.1 types instantiation performance - Improved BER/CER/DER decoder performance by not unconditionally casting substrate into str/bytes. +- Fixed exponential index size growth bug when building ambigious + NamedTypes tree - Fixed constructed types decoding failure at BER codec if running in unguided mode - Fixed crash on prettyPrint'ing a SEQUENCE with no defined components diff --git a/pyasn1/type/namedtype.py b/pyasn1/type/namedtype.py index 25e07a2..bc541db 100644 --- a/pyasn1/type/namedtype.py +++ b/pyasn1/type/namedtype.py @@ -106,13 +106,13 @@ class NamedTypes(object): ---------- *namedTypes: :class:`~pyasn1.type.namedtype.NamedType` """ - def __init__(self, *namedTypes): + def __init__(self, *namedTypes, **kwargs): self.__namedTypes = namedTypes self.__namedTypesLen = len(self.__namedTypes) self.__minTagSet = self.__computeMinTagSet() self.__nameToPosMap = self.__computeNameToPosMap() self.__tagToPosMap = self.__computeTagToPosMap() - self.__ambiguousTypes = self.__computeAmbiguousTypes() + self.__ambiguousTypes = 'terminal' not in kwargs and self.__computeAmbiguousTypes() or {} self.__uniqueTagMap = self.__computeTagMaps(unique=True) self.__nonUniqueTagMap = self.__computeTagMaps(unique=False) self.__hasOptionalOrDefault = bool([True for namedType in self.__namedTypes @@ -229,7 +229,7 @@ class NamedTypes(object): if len(partialAmbigiousTypes) == len(self.__namedTypes): ambigiousTypes[idx] = self else: - ambigiousTypes[idx] = NamedTypes(*partialAmbigiousTypes) + ambigiousTypes[idx] = NamedTypes(*partialAmbigiousTypes, terminal=True) return ambigiousTypes def getTypeByPosition(self, idx): @@ -394,13 +394,16 @@ class NamedTypes(object): minTagSet = None for namedType in self.__namedTypes: asn1Object = namedType.asn1Object + try: tagSet = asn1Object.minTagSet except AttributeError: tagSet = asn1Object.tagSet + if minTagSet is None or tagSet < minTagSet: minTagSet = tagSet + return minTagSet or tag.TagSet() @property |