Issue 720908: datetime types don't work as bases (original) (raw)

Created on 2003-04-14 04:58 by tim.peters, last changed 2022-04-10 16:08 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
datetime.fix gvanrossum,2003-04-14 17:26 Strawman fix
Messages (6)
msg15446 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-04-14 04:58
This is probably shallow. Assigned to Guido in case it's very shallow : >>> from datetime import * >>> class C(date): ... def whatever(self): ... return "oops" >>> c = C(2002, 1, 1) >>> c.whatever() Traceback (most recent call last): File "", line 1, in ? AttributeError: 'datetime.date' object has no attribute 'whatever' >>> type(c) <type 'datetime.date'> >>> Was reported on c.l.py.
msg15447 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-04-14 12:04
Logged In: YES user_id=6380 Well, one shallow thing becomes obvious when you write c.__class__: it's date, not C! Back to Tim...
msg15448 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-04-14 17:26
Logged In: YES user_id=6380 Here's a strawman fix. It makes 'date' a properly subclassable type, and makes all the other types (except tzinfo) non-subclassable.
msg15449 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-04-14 22:02
Logged In: YES user_id=31435 I think the date enhancement is fine -- check it in! I'd leave off removing the basetype flag on the other types, though -- I expect we'll need to make them subclassable too.
msg15450 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-04-14 22:20
Logged In: YES user_id=6380 Done; the rest is up to you!
msg15451 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-05-17 17:40
Logged In: YES user_id=31435 I checked in changes (for 2.3b2) so that time, datetime, and timedelta are properly subclassable from Python too. That's all of 'em, so closing this now.
History
Date User Action Args
2022-04-10 16:08:07 admin set github: 38298
2003-04-14 04:58:53 tim.peters create