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 amaury.forgeotdarc
Recipients amaury.forgeotdarc, barry-scott
Date 2008-09-06.20:11:42
SpamBayes Score 3.6637408e-05
Marked as misclassified No
Message-id <1220731903.83.0.425187774359.issue3777@psf.upfronthosting.co.za>
In-reply-to
Content
You are right: long(4.2) used to return a long.

This was changed by the introduction of the float_trunc() function,
which is now used for float.__trunc__, float.__int__ and float.__long__.

OTOH, long() has always been allowed to return an int. Checked with
python2.2:
>>> class C:
...   def __long__(self): return 4
...
>>> type(long(C()))
<type 'int'>

I suggest that:
- your code should be more tolerant, specially when calling API
functions from the "Abstract Objects Layer", accept both longs and ints.
- Concerning long(float()), the new behavior breaks existing code, and
should be reverted. I will try to come with a patch.
History
Date User Action Args
2008-09-06 20:11:43amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc, barry-scott
2008-09-06 20:11:43amaury.forgeotdarcsetmessageid: <1220731903.83.0.425187774359.issue3777@psf.upfronthosting.co.za>
2008-09-06 20:11:42amaury.forgeotdarclinkissue3777 messages
2008-09-06 20:11:42amaury.forgeotdarccreate