Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6fd0902

Browse files
xhochyByron
authored andcommitted
Fix pickling of tzoffset
Fixes#650
1 parent95897f9 commit6fd0902

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

‎git/objects/util.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ def __init__(self, secs_west_of_utc, name=None):
105105
self._offset=timedelta(seconds=-secs_west_of_utc)
106106
self._name=nameor'fixed'
107107

108+
def__reduce__(self):
109+
returntzoffset, (-self._offset.total_seconds(),self._name)
110+
108111
defutcoffset(self,dt):
109112
returnself._offset
110113

‎git/test/test_util.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

7+
importpickle
78
importtempfile
89
importtime
910
fromunittestimportskipIf
@@ -280,3 +281,9 @@ def test_from_timestamp(self):
280281
# Wrong offset: UTC-9000, should return datetime + tzoffset(UTC)
281282
altz=utctz_to_altz('-9000')
282283
self.assertEqual(datetime.fromtimestamp(1522827734,tzoffset(0)),from_timestamp(1522827734,altz))
284+
285+
deftest_pickle_tzoffset(self):
286+
t1=tzoffset(555)
287+
t2=pickle.loads(pickle.dumps(t1))
288+
self.assertEqual(t1._offset,t2._offset)
289+
self.assertEqual(t1._name,t2._name)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp