Josh Rosenberg added the comment:

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! :-)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20858>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to