Message84297
Thanks for the patch, Victor. I think this is the right thing to do,
though I'm still not sure why anyone would care about getting longs
instead of ints back from int(x).
Comments and questions:
(0) Please could you add some tests!
(1) Shouldn't the first line you added include a check for res == NULL?
(2) It looks as though the patched code ends up calling PyLong_Check twice
when __int__ returns a long. Can you find a clear rewrite that avoids
this duplication?
By the way, I realized after posting my last comment that the issue with
Fraction has nothing to do with extreme int values. For example, with the
current trunk (not including Victor's patch):
>>> int(Fraction(2L))
2L
>>> int(int(Fraction(2L)))
2
I don't think should be considered a bug in Fraction---I think Victor's
solution of making the int() machinery always return int when possible is
the right one here. The need to call int(int(x)) if you *really* want an
int seems a little ugly. |
|
Date |
User |
Action |
Args |
2009-03-28 04:22:07 | mark.dickinson | set | recipients:
+ mark.dickinson, rhettinger, terry.reedy, vstinner, debedb |
2009-03-28 04:22:06 | mark.dickinson | set | messageid: <1238214126.8.0.75073675188.issue5377@psf.upfronthosting.co.za> |
2009-03-28 04:22:05 | mark.dickinson | link | issue5377 messages |
2009-03-28 04:22:03 | mark.dickinson | create | |
|