diff options
Diffstat (limited to 'pyasn1/codec/native')
-rw-r--r-- | pyasn1/codec/native/decoder.py | 10 | ||||
-rw-r--r-- | pyasn1/codec/native/encoder.py | 11 |
2 files changed, 13 insertions, 8 deletions
diff --git a/pyasn1/codec/native/decoder.py b/pyasn1/codec/native/decoder.py index 04ae129..db30c71 100644 --- a/pyasn1/codec/native/decoder.py +++ b/pyasn1/codec/native/decoder.py @@ -181,11 +181,13 @@ class SingleItemDecoder(object): class Decoder(object): - SINGLE_ITEM_DECODER = SingleItemDecoder() + SINGLE_ITEM_DECODER = SingleItemDecoder - @classmethod - def __call__(cls, pyObject, asn1Spec=None, **kwargs): - return cls.SINGLE_ITEM_DECODER(pyObject, asn1Spec=asn1Spec, **kwargs) + def __init__(self, **options): + self._singleItemDecoder = self.SINGLE_ITEM_DECODER() + + def __call__(self, pyObject, asn1Spec=None, **kwargs): + return self._singleItemDecoder(pyObject, asn1Spec=asn1Spec, **kwargs) #: Turns Python objects of built-in types into ASN.1 objects. diff --git a/pyasn1/codec/native/encoder.py b/pyasn1/codec/native/encoder.py index 0001916..d0d65ec 100644 --- a/pyasn1/codec/native/encoder.py +++ b/pyasn1/codec/native/encoder.py @@ -225,11 +225,14 @@ class SingleItemEncoder(object): class Encoder(object): - SINGLE_ITEM_ENCODER = SingleItemEncoder() + SINGLE_ITEM_ENCODER = SingleItemEncoder - @classmethod - def __call__(cls, pyObject, asn1Spec=None, **kwargs): - return cls.SINGLE_ITEM_ENCODER(pyObject, asn1Spec=asn1Spec, **kwargs) + def __init__(self, **kwargs): + self._singleItemEncoder = self.SINGLE_ITEM_ENCODER() + + def __call__(self, pyObject, asn1Spec=None, **options): + return self._singleItemEncoder( + pyObject, asn1Spec=asn1Spec, **options) #: Turns ASN.1 object into a Python built-in type object(s). |