summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.rst1
-rw-r--r--iso8601/iso8601.py5
-rw-r--r--iso8601/test_iso8601.py4
3 files changed, 10 insertions, 0 deletions
diff --git a/README.rst b/README.rst
index c35624d..284ab9f 100644
--- a/README.rst
+++ b/README.rst
@@ -72,6 +72,7 @@ Changes
* Correctly raise ParseError for more invalid inputs (https://bitbucket.org/micktwomey/pyiso8601/issue/1/raise-parseerror-for-invalid-input) (thanks to manish.tomar)
* Support more variations of ISO 8601 dates, times and time zone specs.
* Fix microsecond rounding issues (https://bitbucket.org/micktwomey/pyiso8601/issue/2/roundoff-issues-when-parsing-decimal) (thanks to nielsenb@jetfuse.net)
+* Fix pickling and deepcopy of returned datetime objects (https://bitbucket.org/micktwomey/pyiso8601/issue/3/dates-returned-by-parse_date-do-not) (thanks to fogathmann and john@openlearning.com)
0.1.4
-----
diff --git a/iso8601/iso8601.py b/iso8601/iso8601.py
index b979f02..86c076b 100644
--- a/iso8601/iso8601.py
+++ b/iso8601/iso8601.py
@@ -82,6 +82,8 @@ class FixedOffset(tzinfo):
"""
def __init__(self, offset_hours, offset_minutes, name):
+ self.__offset_hours = offset_hours # Keep for later __getinitargs__
+ self.__offset_minutes = offset_minutes # Keep for later __getinitargs__
self.__offset = timedelta(hours=offset_hours, minutes=offset_minutes)
self.__name = name
@@ -96,6 +98,9 @@ class FixedOffset(tzinfo):
return other == self
return False
+ def __getinitargs__(self):
+ return (self.__offset_hours, self.__offset_minutes, self.__name)
+
def utcoffset(self, dt):
return self.__offset
diff --git a/iso8601/test_iso8601.py b/iso8601/test_iso8601.py
index 4a0b05c..a696038 100644
--- a/iso8601/test_iso8601.py
+++ b/iso8601/test_iso8601.py
@@ -1,7 +1,9 @@
# coding=UTF-8
from __future__ import absolute_import
+import copy
import datetime
+import pickle
import pytest
@@ -60,3 +62,5 @@ def test_parse_valid_date(valid_date, expected_datetime):
assert parsed.tzinfo == expected_datetime.tzinfo
assert parsed == expected_datetime
assert parsed.isoformat() == expected_datetime.isoformat()
+ copy.deepcopy(parsed) # ensure it's deep copy-able
+ pickle.dumps(parsed) # ensure it pickles \ No newline at end of file