[python-win32] Python 3 --> Can't pickle <class'pywintypes.datetime'>
Roger Upole
rupole at hotmail.com
Thu Apr 18 23:26:03 CEST 2013
The pickle module is looking at the name of the class, and verifying that
there's a module.class that matches. However, our subclass of
datetime.datetime is registered in pywintypes' dict as TimeType
instead. As a workaround, try
pywintypes.datetime = pywintypes.TimeType
Roger
"Vernon D. Cole" <vernondcole at gmail.com> wrote in message news:CAH-ZgAe7Lot7ng1mVU4figK0OBSbDRQqWtxUpgZ0CPg9WTbANQ at mail.gmail.com...
> Help me, Obiwan Kanobi...
>
> I have been tracking this one down, for two days, and have cleaned by my
> data conversion routines and the documentation for them as a result. but I
> can't determine the "right" way to fix this.
>
> This works fine in Python 2, but in Python 3, the class of a datetime
> retrieved from COM is different. I can send them across a PyRO link in
> Python 2, when I try it in Python 3 I get: the error:
>
> adodbapi.apibase.DatabaseError: Can't pickle <class 'pywintypes.datetime'>:
> attribute lookup pywintypes.datetime failed
>
> The conversion code I use is:
>
> def DateObjectFromCOMDate(self,comDate):
> if isinstance(comDate,datetime.datetime):
> return comDate.replace(tzinfo=None) # make non aware
>
> Which returns a pywintypes.datetime, which, as you see, will not pickle.
>
> Any suggestions?
> --
> Vernon
>
--------------------------------------------------------------------------------
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
More information about the python-win32
mailing list