public inbox for pyderasn-devel@lists.cypherpunks.ru
Atom feed
* [pyderasn-devel] [Bug] UTCTime with offset-aware datetimes fails equality check
@ 2020-04-13 13:06 Nikolay Ivanov
  2020-04-13 14:39 ` Sergey Matveev
  0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Ivanov @ 2020-04-13 13:06 UTC (permalink / raw)
  To: pyderasn-devel

Pyderasn Version: 7.7

Steps to reproduce:

dt = datetime(1990, 1, 1, 0, 0, tzinfo=tzutc())

ut = UTCTime(dt)

nut = UTCTime().decod(ut.encode())

ut == nut

>>> False

GeneralizedTime also fails this check.



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [pyderasn-devel] [Bug] UTCTime with offset-aware datetimes fails equality check
  2020-04-13 13:06 [pyderasn-devel] [Bug] UTCTime with offset-aware datetimes fails equality check Nikolay Ivanov
@ 2020-04-13 14:39 ` Sergey Matveev
  0 siblings, 0 replies; 2+ messages in thread
From: Sergey Matveev @ 2020-04-13 14:39 UTC (permalink / raw)
  To: pyderasn-devel

[-- Attachment #1: Type: text/plain, Size: 994 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-13 14:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-13 13:06 [pyderasn-devel] [Bug] UTCTime with offset-aware datetimes fails equality check Nikolay Ivanov
2020-04-13 14:39 ` Sergey Matveev