Message277729
Ah, I should have read more about __int__ and __index__ before writing my last reply.
So IIUC, this is a somewhat painful issue, which could be resolved by:
* #20092
* replacing _PyLong_FromNbInt with PyNumber_Index in:
- Objects/longobject.c (as you suggested in https://bugs.python.org/issue12965#msg146252)
- Modules/zlibmodule.c in ssize_t_converter
I didn't find any issue for the second one. If there is really no such issue, why is that? (I am sorry if I am the thousandth one to ask)
The first paragraph of your comment in https://bugs.python.org/issue21111#msg215660 suggests it might break a lot of code in the wild, but shouldn't we start with raising a deprecation warning?
With regard to my patch - should I make the following changes?
1. in Modules/arraymodule.c - add a call to PyNumber_Index before the call to _PyLong_FromNbInt (and move them into a helper function, as done in Modules/_struct.c)
2. in Lib/test/test_array.py:
* replace the name 'LikeInt' with 'IntCompatible' (I am not sure this is an appropriate name either. If you have a better name in mind, please share :) )
* add tests for LikeInt (this time, a class with a __index__ method)
3. In Doc/library/array.rst:
* add a note saying that setting int-like objects (i.e. objects with __index__) to items in an integers array is possible
* while we are here, remove the note about the availability of 'q' and 'Q' only in certain platforms |
|
Date |
User |
Action |
Args |
2016-09-29 21:15:45 | Oren Milman | set | recipients:
+ Oren Milman, mark.dickinson, meador.inge, serhiy.storchaka |
2016-09-29 21:15:45 | Oren Milman | set | messageid: <1475183745.79.0.735898267771.issue28298@psf.upfronthosting.co.za> |
2016-09-29 21:15:45 | Oren Milman | link | issue28298 messages |
2016-09-29 21:15:45 | Oren Milman | create | |
|