]> Cypherpunks.ru repositories - pyderasn.git/blobdiff - pyderasn.py
Explicitly forbid aware-datetimes usage
[pyderasn.git] / pyderasn.py
index 505f3baafac8516084242256bb12f2633f02ace0..516715a7f2e419a6d1070c03eee7f2c07bb1b895 100755 (executable)
@@ -1201,7 +1201,7 @@ except ImportError:  # pragma: no cover
     def colored(what, *args, **kwargs):
         return what
 
-__version__ = "7.7"
+__version__ = "8.0"
 
 __all__ = (
     "agg_octet_string",
@@ -5080,13 +5080,20 @@ class UTCTime(VisibleString):
 
     .. warning::
 
-       Pay attention that UTCTime can not hold full year, so all years
-       having < 50 years are treated as 20xx, 19xx otherwise, according
-       to X.509 recommendation.
+       Only **naive** ``datetime`` objects are supported.
+       Library assumes that all work is done in UTC.
 
     .. warning::
 
-       No strict validation of UTC offsets are made, but very crude:
+       Pay attention that ``UTCTime`` can not hold full year, so all years
+       having < 50 years are treated as 20xx, 19xx otherwise, according to
+       X.509 recommendation. Use ``GeneralizedTime`` instead for
+       removing ambiguity.
+
+    .. warning::
+
+       No strict validation of UTC offsets are made (only applicable to
+       **BER**), but very crude:
 
        * minutes are not exceeding 60
        * offset value is not exceeding 14 hours
@@ -5213,6 +5220,8 @@ class UTCTime(VisibleString):
         if isinstance(value, self.__class__):
             return value._value, None
         if value.__class__ == datetime:
+            if value.tzinfo is not None:
+                raise ValueError("only naive datetime supported")
             return self._dt_sanitize(value), None
         raise InvalidValueType((self.__class__, datetime))
 
@@ -5323,23 +5332,23 @@ class GeneralizedTime(UTCTime):
 
     .. warning::
 
-       Only microsecond fractions are supported in DER encoding.
-       :py:exc:`pyderasn.DecodeError` will be raised during decoding of
-       higher precision values.
+       Only **naive** datetime objects are supported.
+       Library assumes that all work is done in UTC.
 
     .. warning::
 
-       BER encoded data can loss information (accuracy) during decoding
-       because of float transformations.
+       Only **microsecond** fractions are supported in DER encoding.
+       :py:exc:`pyderasn.DecodeError` will be raised during decoding of
+       higher precision values.
 
     .. warning::
 
-       Local times (without explicit timezone specification) are treated
-       as UTC one, no transformations are made.
+       **BER** encoded data can loss information (accuracy) during
+       decoding because of float transformations.
 
     .. warning::
 
-       Zero year is unsupported.
+       **Zero** year is unsupported.
     """
     __slots__ = ()
     tag_default = tag_encode(24)