Skip to content

Commit

Permalink
fixed ASN.1 time types deepcopy/pickle operations
Browse files Browse the repository at this point in the history
  • Loading branch information
etingof committed Sep 26, 2017
1 parent 57b7faf commit 03201a7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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
-----------------------------------

Expand Down
2 changes: 1 addition & 1 deletion pyasn1/__init__.py
Original file line number Diff line number Diff line change
@@ -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')
6 changes: 4 additions & 2 deletions pyasn1/type/useful.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):
Expand Down
5 changes: 5 additions & 0 deletions tests/type/test_useful.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
import sys
import datetime
from copy import deepcopy

try:
import unittest2 as unittest
Expand Down Expand Up @@ -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):

Expand Down

0 comments on commit 03201a7

Please sign in to comment.