diff --git a/CHANGES.rst b/CHANGES.rst index c3afa14f..1d18f95e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,4 +1,9 @@ +Revision 0.3.7, released XX-09-2017 +----------------------------------- + +- Fixed ASN.1 time types pickling/deepcopy'ing + Revision 0.3.6, released 21-09-2017 ----------------------------------- diff --git a/pyasn1/__init__.py b/pyasn1/__init__.py index e7720b47..c9218a04 100644 --- a/pyasn1/__init__.py +++ b/pyasn1/__init__.py @@ -1,7 +1,7 @@ import sys # http://www.python.org/dev/peps/pep-0396/ -__version__ = '0.3.6' +__version__ = '0.3.7' if sys.version_info[:2] < (2, 4): raise RuntimeError('PyASN1 requires Python 2.4 or later') diff --git a/pyasn1/type/useful.py b/pyasn1/type/useful.py index 1338e6ae..a05a9a60 100644 --- a/pyasn1/type/useful.py +++ b/pyasn1/type/useful.py @@ -37,7 +37,9 @@ class TimeMixIn(object): class FixedOffset(datetime.tzinfo): """Fixed offset in minutes east from UTC.""" - def __init__(self, offset, name): + # defaulted arguments required + # https: // docs.python.org / 2.3 / lib / datetime - tzinfo.html + def __init__(self, offset=0, name='UTC'): self.__offset = datetime.timedelta(minutes=offset) self.__name = name @@ -50,7 +52,7 @@ def tzname(self, dt): def dst(self, dt): return datetime.timedelta(0) - UTC = FixedOffset(0, 'UTC') + UTC = FixedOffset() @property def asDateTime(self): diff --git a/tests/type/test_useful.py b/tests/type/test_useful.py index 717eede6..82a97d7e 100644 --- a/tests/type/test_useful.py +++ b/tests/type/test_useful.py @@ -6,6 +6,7 @@ # import sys import datetime +from copy import deepcopy try: import unittest2 as unittest @@ -72,6 +73,10 @@ def testToDateTime7(self): def testToDateTime8(self): assert datetime.datetime(2017, 7, 11, 0) == useful.GeneralizedTime('2017071100').asDateTime + def testCopy(self): + dt = useful.GeneralizedTime("20170916234254+0130").asDateTime + assert dt == deepcopy(dt) + class UTCTimeTestCase(BaseTestCase):