diff options
author | Jörn Heissler <nosuchaddress@joern.heissler.de> | 2019-11-11 22:36:32 +0100 |
---|---|---|
committer | Jörn Heissler <nosuchaddress@joern.heissler.de> | 2019-11-11 22:56:06 +0100 |
commit | 20e2b4ed3ee3a4cab080ba8b4f98aee94316e01c (patch) | |
tree | 8fd2b713c8abfeb5f729fe67add1cf99385422b9 /asn1crypto | |
parent | 63ffc710ad3cbf85876ce591e82be9fea47fcad7 (diff) | |
download | asn1crypto-20e2b4ed3ee3a4cab080ba8b4f98aee94316e01c.tar.gz |
Add __getinitargs__ method to util.timezone
If a timezone object is copied, its __reduce__ method is called which in
turn calls __getinitargs__ to get arguments for __init__ on the new
object.
If that function is missing, __init_ is called with too few parameters.
Problem can be triggered by calling copy or untag on UTCTime or GeneralizedTime
or any other object where the native value includes a datetime
Fixes #167
Diffstat (limited to 'asn1crypto')
-rw-r--r-- | asn1crypto/util.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/asn1crypto/util.py b/asn1crypto/util.py index 4d743df..7196897 100644 --- a/asn1crypto/util.py +++ b/asn1crypto/util.py @@ -161,6 +161,16 @@ if sys.version_info <= (3,): return False return self._offset == other._offset + def __getinitargs__(self): + """ + Called by tzinfo.__reduce__ to support pickle and copy. + + :return: + offset and name, to be used for __init__ + """ + + return self._offset, self._name + def tzname(self, dt): """ :param dt: |