Mark Dickinson <[EMAIL PROTECTED]> added the comment: With the patch, the following code causes a non-keyboard-interruptible interpreter hang.
>>> from sys import maxint >>> (-maxint-1).numbits() [... interpreter hang ...] The culprit is, of course, the statement if (n < 0) n = -n; in int_numbits: LONG_MIN is negated to itself (this may even be undefined behaviour according to the C standards). The patch also needs documentation, and that documentation should clearly spell out what happens for zero and for negative numbers. It's not at all clear that everyone will expect (0).numbits() to be 0, though I agree that this is probably the most useful definition in practice. One could make a case for (0).numbits() raising ValueError: for some algorithms, what one wants is an integer k such that 2**(k-1) <= abs(n) < 2**k; when n == 0 no such integer exists. Other than those two things, I think the patch looks fine. _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3439> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com