Serhiy Storchaka added the comment:

Now pickling of the datetime.datetime objects is implemented with 
__reduce_ex__. __reduce__ is not defined in datetime.datetime and is inherited 
from datetime.date.

>>> datetime.datetime.__reduce_ex__
<method '__reduce_ex__' of 'datetime.datetime' objects>
>>> datetime.datetime.__reduce__
<method '__reduce__' of 'datetime.date' objects>

__reduce_ex__ has higher priority and is called instead of __reduce__. It is 
weird that __reduce_ex__ and __reduce__ are not consistent. __reduce__ should 
be defined as

    def __reduce__(self):
        return self.__reduce_ex__(2)

or just

    __reduce__ = object.__reduce__

Other way is to define __reduce_ex__ instead of __reduce__ in datetime.date.

----------
components: +Extension Modules
nosy: +belopolsky, serhiy.storchaka
type:  -> behavior

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28752>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to