From bac135a0ac35acb6ebefa683541fc34b920f7671 Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Sat, 7 Sep 2019 18:16:28 +0200 Subject: [PATCH] Improve open maps debugging in decoder --- pyasn1/codec/ber/decoder.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/pyasn1/codec/ber/decoder.py b/pyasn1/codec/ber/decoder.py index 5759ab81..5ff485fb 100644 --- a/pyasn1/codec/ber/decoder.py +++ b/pyasn1/codec/ber/decoder.py @@ -638,7 +638,10 @@ def valueDecoder(self, substrate, asn1Spec, openTypes = options.get('openTypes', {}) if LOG: - LOG('using open types map: %r' % openTypes) + LOG('user-specified open types map:') + + for k, v in openTypes.items(): + LOG('%s -> %r' % (k, v)) if openTypes or options.get('decodeOpenTypes', False): @@ -658,6 +661,17 @@ def valueDecoder(self, substrate, asn1Spec, except KeyError: + if LOG: + LOG('default open types map of component ' + '"%s.%s" governed by component "%s.%s"' + ':' % (asn1Object.__class__.__name__, + namedType.name, + asn1Object.__class__.__name__, + namedType.openType.name)) + + for k, v in namedType.openType.items(): + LOG('%s -> %r' % (k, v)) + try: openType = namedType.openType[governingValue] @@ -823,7 +837,10 @@ def indefLenValueDecoder(self, substrate, asn1Spec, openTypes = options.get('openTypes', {}) if LOG: - LOG('using open types map: %r' % openTypes) + LOG('user-specified open types map:') + + for k, v in openTypes.items(): + LOG('%s -> %r' % (k, v)) if openTypes or options.get('decodeOpenTypes', False): @@ -843,6 +860,17 @@ def indefLenValueDecoder(self, substrate, asn1Spec, except KeyError: + if LOG: + LOG('default open types map of component ' + '"%s.%s" governed by component "%s.%s"' + ':' % (asn1Object.__class__.__name__, + namedType.name, + asn1Object.__class__.__name__, + namedType.openType.name)) + + for k, v in namedType.openType.items(): + LOG('%s -> %r' % (k, v)) + try: openType = namedType.openType[governingValue]