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 mark.dickinson
Recipients fredrikj, loewis, mark.dickinson, rhettinger
Date 2008-08-14.09:47:09
SpamBayes Score 5.257902e-05
Marked as misclassified No
Message-id <1218707231.58.0.459715716283.issue3439@psf.upfronthosting.co.za>
In-reply-to
Content
One possible fix would be to compute the absolute value
of n as an unsigned long. I *think* the following is
portable and avoids any undefined behaviour coming
from signed arithmetic overflow.

unsigned long absn;
if (n < 0)
	absn = 1 + (unsigned long)(-1-n);
else
	absn = (unsigned long)n;

Might this work?

Perhaps it would also be worth changing the tests
in test_int from e.g.

self.assertEqual((-a).numbits(), i+1)

to

self.assertEqual(int(-a).numbits(), i+1)

This would have caught the -LONG_MAX error.
History
Date User Action Args
2008-08-14 09:47:11mark.dickinsonsetrecipients: + mark.dickinson, loewis, rhettinger, fredrikj
2008-08-14 09:47:11mark.dickinsonsetmessageid: <1218707231.58.0.459715716283.issue3439@psf.upfronthosting.co.za>
2008-08-14 09:47:10mark.dickinsonlinkissue3439 messages
2008-08-14 09:47:10mark.dickinsoncreate