Skip to content

Commit 374d1da

Browse files
committed
Fix deepcopy() raising an error when using UTC
1 parent 1d71460 commit 374d1da

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
### Fixed
66

77
- Fixed an offset error when subtracting datetimes in the same timezone.
8-
- Fixed wrong value returned by `tzname()` for the UTC timezone
8+
- Fixed wrong value returned by `tzname()` for the UTC timezone.
9+
- Fixed `deepcopy()` raising an error when using `UTC`.
910

1011

1112
## [1.4.1] - 2018-02-05

pendulum/tz/timezone_info.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,8 @@ def dst(self, dt):
134134
def fromutc(self, dt):
135135
return dt.replace(tzinfo=self)
136136

137+
def __getinitargs__(self):
138+
return ()
139+
140+
137141
UTC = _UTC()

tests/pendulum_tests/test_behavior.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ def test_deepcopy_datetime(self):
125125

126126
self.assertEqual(dt._datetime, deepcopy(dt._datetime))
127127

128+
def test_deepcopy_datetime_utcnow(self):
129+
dt = pendulum.utcnow()
130+
131+
self.assertEqual(dt._datetime, deepcopy(dt._datetime))
132+
128133
def test_pickle_timezone(self):
129134
dt1 = pendulum.timezone('Europe/Amsterdam')
130135
s = pickle.dumps(dt1)

0 commit comments

Comments
 (0)