On 29 December 2017 at 22:58, Erik Bray <erik.m.bray@gmail.com> wrote:
On Thu, Dec 28, 2017 at 8:42 PM, Serhiy Storchaka <storchaka@gmail.com> wrote:
28.12.17 12:10, Erik Bray пише:
There's no index() alternative to int().
operator.index()
Okay, and it's broken.
Broken in what way? It has a fairly extensive test suite in https://github.com/python/cpython/blob/master/Lib/test/test_index.py (and some additional indirect testing in test_slice.py, which assumes that it works as advertised).
That doesn't change my other point that some functions that could previously take non-int arguments can no longer--if we agree on that at least then I can set about making a bug report and fixing it.
The size_t, ssize_t and void pointer conversions should only accept true integers (so either no fallback, or fall back to `__index__`). The unsigned long and unsigned long long conversions should likely be consistent with their signed counterparts and allow lossy conversions via `__int__`. I'm less sure about the conversion to double, but allowing that to be used on float objects without reporting a type error seems like a bug magnet to me. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia