Message235773
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] |
|
Date |
User |
Action |
Args |
2015-02-11 22:19:31 | eddygeek | set | recipients:
+ eddygeek, belopolsky, r.david.murray, yselivanov, Andrew.Lutomirski |
2015-02-11 22:19:31 | eddygeek | set | messageid: <1423693171.23.0.425798587808.issue20371@psf.upfronthosting.co.za> |
2015-02-11 22:19:31 | eddygeek | link | issue20371 messages |
2015-02-11 22:19:30 | eddygeek | create | |
|