Module has to be specified for namedtuples for pickling under Cython.
automatically set required tags)
* Descriptive errors, like ``pyderasn.DecodeError: UTCTime
(tbsCertificate:validity:notAfter:utcTime) (at 328) invalid UTCTime format``
-* ``__slots__``, ``copy.copy()``, ``pickle`` friendliness
+* ``__slots__``, ``copy.copy()``, ``pickle``, `Cython <https://cython.org/>`__
+ friendliness
* Could be significantly faster and have lower memory usage
For example parsing of CACert.org's CRL (8.48 MiB) on FreeBSD 12.0
amd64, Intel Core i5-6200U 2.3 GHz machine, Python 3.5.5/2.7.15:
* UTCTime and GeneralizedTime allowed values to have plus sign in them,
passing int() check successfully. Prohibit that incorrect behaviour
* UTCTime and GeneralizedTime BER decoding support
+* Workability under Cython
* Explicitly Check that all ObjectIdentifier arcs are non-negative
.. _release6.0:
#!/usr/bin/env python
# coding: utf-8
+# cython: language_level=3
# PyDERASN -- Python ASN.1 DER/BER codec with abstract structures
# Copyright (C) 2017-2020 Sergey Matveev <stargrave@stargrave.org>
#
EOC_LEN = len(EOC)
LENINDEF = b"\x80" # length indefinite mark
LENINDEF_PP_CHAR = "I" if PY2 else "∞"
+NAMEDTUPLE_KWARGS = {} if PY2 else {"module": __name__}
########################################################################
"lenindef",
"ber_encoded",
"bered",
-))
+), **NAMEDTUPLE_KWARGS)
def _pp(
"expl_lenindef",
"lenindef",
"ber_encoded",
-))
+), **NAMEDTUPLE_KWARGS)
class Boolean(Obj):
"expl_lenindef",
"lenindef",
"ber_encoded",
-))
+), **NAMEDTUPLE_KWARGS)
class Integer(Obj):
"ber_encoded",
"tag_constructed",
"defined",
-))
+), **NAMEDTUPLE_KWARGS)
class BitString(Obj):
"ber_encoded",
"tag_constructed",
"defined",
-))
+), **NAMEDTUPLE_KWARGS)
class OctetString(Obj):
"expl_lenindef",
"lenindef",
"ber_encoded",
-))
+), **NAMEDTUPLE_KWARGS)
class Null(Obj):
"lenindef",
"ber_encoded",
"defines",
-))
+), **NAMEDTUPLE_KWARGS)
def pureint(value):
PrintableStringState = namedtuple(
"PrintableStringState",
OctetStringState._fields + ("allowable_chars",),
+ **NAMEDTUPLE_KWARGS
)
asn1_type_name = "VisibleString"
-UTCTimeState = namedtuple("UTCTimeState", OctetStringState._fields + ("ber_raw",))
+UTCTimeState = namedtuple(
+ "UTCTimeState",
+ OctetStringState._fields + ("ber_raw",),
+ **NAMEDTUPLE_KWARGS
+)
class UTCTime(VisibleString):
"expl_lenindef",
"lenindef",
"ber_encoded",
-))
+), **NAMEDTUPLE_KWARGS)
class Choice(Obj):
"lenindef",
"ber_encoded",
"defined",
-))
+), **NAMEDTUPLE_KWARGS)
class Any(Obj):
"expl_lenindef",
"lenindef",
"ber_encoded",
-))
+), **NAMEDTUPLE_KWARGS)
class Sequence(Obj):
"expl_lenindef",
"lenindef",
"ber_encoded",
-))
+), **NAMEDTUPLE_KWARGS)
class SequenceOf(Obj):