homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eddygeek
Recipients Andrew.Lutomirski, belopolsky, eddygeek, r.david.murray, yselivanov
Date 2015年02月11日.22:19:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1423693171.23.0.425798587808.issue20371@psf.upfronthosting.co.za>
In-reply-to
Content
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]
History
Date User Action Args
2015年02月11日 22:19:31eddygeeksetrecipients: + eddygeek, belopolsky, r.david.murray, yselivanov, Andrew.Lutomirski
2015年02月11日 22:19:31eddygeeksetmessageid: <1423693171.23.0.425798587808.issue20371@psf.upfronthosting.co.za>
2015年02月11日 22:19:31eddygeeklinkissue20371 messages
2015年02月11日 22:19:30eddygeekcreate

AltStyle によって変換されたページ (->オリジナル) /