leapfrogonline/scio — pull request #7 by jstern (2013-10-02 17:06:51+00:00)
Title: handle binary time 'string' from pickle

I'm running into a situation where I sporadically get ValueErrors while attempting to unpickle TimeType objects. Adding a loads(dumps()) test demonstrates the error:

$ ./test.sh
GLOB sdist-make: /Users/jstern/working/public/scio/setup.py
py26 inst-nodeps: /Users/jstern/working/public/scio/.tox/dist/Scio-0.12.1.zip
py26 runtests: commands[0] | nosetests
..............................................................................E.....
======================================================================
ERROR: test_types.test_time_pickles
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/jstern/working/public/scio/.tox/py26/lib/python2.6/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/Users/jstern/working/public/scio/tests/test_types.py", line 109, in test_time_pickles
dt = loads(dumps(dt))
File "/Users/jstern/working/public/scio/scio/client.py", line 440, in __new__
newarg, newkw = cls.adapt_args(arg, kw)
File "/Users/jstern/working/public/scio/scio/client.py", line 561, in adapt_args
dt = parse_date(newarg[0])
File "/Users/jstern/working/public/scio/.tox/py26/lib/python2.6/site-packages/dateutil/parser.py", line 697, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File "/Users/jstern/working/public/scio/.tox/py26/lib/python2.6/site-packages/dateutil/parser.py", line 303, in parse
raise ValueError, "unknown string format"
ValueError: (ValueError('unknown string format',), , ('\x063\x15\x00\x00\x00',))

With the change to catch the ValueError and return the args as-is (like DateTimeType does) the new test passes. Not sure why I'm seeing the behavior inconsistently, but does this change look safe to include?