Message212852
That's actually an argument to fix the C datetime implementation. Right now, you get:
>>> from decimal import Decimal as d
>>> from datetime import datetime
>>> datetime(d("2000.5"), 1, 2)
datetime.datetime(2000, 1, 2, 0, 0)
This is wildly inconsistent; if you passed 2000.0, it would raise an exception because float (even floats directly equivalent to an int value) are forbidden. But the logically equivalent Decimal type will work just fine, silently truncating. Basically any user defined type with integer coercion (but not integer equivalence) would have the same problem; str doesn't, because str is special cased (it doesn't actually have __int__), but any user-defined str-like class that defined int coercion would work as a datetime arg in a way str does not.
You've just given me an excuse to open my first bug. Thanks! :-) |
|
Date |
User |
Action |
Args |
2014-03-06 23:26:26 | josh.r | set | recipients:
+ josh.r, lemburg, tim.peters, belopolsky, bdkearns |
2014-03-06 23:26:26 | josh.r | set | messageid: <1394148386.18.0.379799811588.issue20858@psf.upfronthosting.co.za> |
2014-03-06 23:26:26 | josh.r | link | issue20858 messages |
2014-03-06 23:26:25 | josh.r | create | |
|