[Python-ideas] Is there a reason some of the PyLong_As* functions don't call an object's __int__?
storchaka at gmail.com
Fri Dec 29 11:04:43 EST 2017
29.12.17 16:43, Nick Coghlan пише:
> On 29 December 2017 at 22:58, Erik Bray <erik.m.bray at gmail.com> wrote:
>> Okay, and it's broken.
> Broken in what way? It has a fairly extensive test suite in
> (and some additional indirect testing in test_slice.py, which assumes
> that it works as advertised).
Unfortunately the pure Python implementation doesn't work correctly in
corner cases (https://bugs.python.org/issue18712). But in CPython the C
implementation is used. Maybe Erik means something other.
> The unsigned long and unsigned long long conversions should likely be
> consistent with their signed counterparts and allow lossy conversions
> via `__int__`.
There is a code that relies on the atomicity of these functions. Calling
__int__ or __index__ will introduce vulnerabilities in the existing code.
More information about the Python-ideas