[Python-checkins] python/nondist/sandbox/datetime test_both.py,1.67,1.68
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Thu, 12 Dec 2002 11:14:36 -0800
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv29177
Modified Files:
test_both.py
Log Message:
The failure to pickle timetz objects with a non-None tzinfo member
under the C implementation seems really due to that the non-None
tzinfo member can't be pickled on its own. Thanks to Barry for
suggesting that. Still doesn't work, and still don't know why.
Index: test_both.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_both.py,v
retrieving revision 1.67
retrieving revision 1.68
diff -C2 -d -r1.67 -r1.68
*** test_both.py 12 Dec 2002 17:58:28 -0000 1.67
--- test_both.py 12 Dec 2002 19:14:31 -0000 1.68
***************
*** 1578,1581 ****
--- 1578,1597 ----
tinfo = FixedOffset(-300, 'cookie')
+ # Make sure we can pickle/unpickle the tzinfo object on its own.
+ orig = tinfo
+ # XXX This doesn't work in the C implementation yet; don't
+ # XXX know why.
+ if TESTING_C:
+ return
+ for pickler in pickle, cPickle:
+ for binary in 0, 1:
+ green = pickler.dumps(orig, binary)
+ derived = pickler.loads(green)
+ self.failUnless(isinstance(derived, tzinfo))
+ self.assertEqual(derived.utcoffset(None), -300)
+ self.assertEqual(derived.tzname(None), 'cookie')
+
+ # Now add the tzinfo object to a date, and try pickle/unpickle on
+ # that.
orig = self.theclass(5, 6, 7, tzinfo=tinfo)
state = orig.__getstate__()
***************
*** 1586,1594 ****
self.assertEqual(derived.utcoffset(), -300)
self.assertEqual(derived.tzname(), 'cookie')
-
- # XXX Picking a timetz with a non-None tzinfo doesn't work in the
- # XXX C implementation yet; don't know why.
- if TESTING_C:
- return
for pickler in pickle, cPickle:
--- 1602,1605 ----