Edward O added the comment: Here is a workaround for subclasses (2&3-compatible):
--- start code --- class MyDate(datetime): @classmethod def fromDT(cls, d): """ :type d: datetime """ return cls(d.year, d.month, d.day, d.hour, d.minute, d.second, d.microsecond, d.tzinfo) def replace(self, *args, **kw): """ :type other: datetime.timedelta :rtype: MyDate """ return self.fromDT(super(MyDate, self).replace(*args, **kw)) --- end code --- This is really a bug and not a misuse as datetime was specifically adapted to be subclassing-friendly. From a look at the (python) source, this seems to be the only bit that was forgotten. The real fix is as per yselivanov comment [and no, this has nothing to do with pickle or copy AFAIK] ---------- versions: +Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20371> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com