Subject: Re: [pyderasn-devel] [Bug] UTCTime with offset-aware datetimes fails equality check

From: Sergey Matveev <[email-masked]>
Date: Mon, 13 Apr 2020 17:39:07 +0300

Greetings!

*** Nikolay Ivanov [2020-04-13 16:06]:
>dt = datetime(1990, 1, 1, 0, 0, tzinfo=tzutc())

PyDERASN has never been aware of timezones in datetimes. It is just
blind to them when encoding. However that is not explicitly mentioned in
documentation and I will fix it.

>ut == nut

Indeed one of them contains original datetime object (with tzinfo set)
and other is decoded one, without any timezone information. I think that
the best thing to do is to explicitly .replace(tzinfo=None) for
initialized datetimes in *Time objects. I will fix it (with
documentation above) in the next release. Or maybe raise an error if
someone uses timezone-away datetime objects, forcing him to make them
neutral? What do you think?

Anyway, if you want to use tzinfo-set objects, then you have to write
your own wrappers. At least DER encoding works only with UTC time.

-- 
Sergey Matveev (http://www.stargrave.org/)
OpenPGP: CF60 E89A 5923 1E76 E263  6422 AE1A 8109 E498 57EF