Repository navigation
Conversation
| if (PyString_Type.tp_as_number) | ||
| stringtype_as_number = *PyString_Type.tp_as_number; | ||
| stringtype_as_number.nb_int = int_from_string; | ||
| stringtype_as_number.nb_float = float_from_string; |
There was a problem hiding this comment.
Why can't you just use - hmm, I see it doesn't have one :(PyString_Type.nb_float here?
>>> "".__float__
AttributeError: 'str' object has no attribute '__float__'
>>> "".__int__
AttributeError: 'str' object has no attribute '__int__'
There was a problem hiding this comment.
Can you just use PyNumber_Int(PyObject_Str(self)) here instead (swapping str for unicode, and int for float as needed)`
|
I don't follow your description of the problem. Do both |
|
Calling Calling Using |
|
I'm suggesting we call |
|
#10042 supersedes this, cleaner and more explicit |
|
Thanks for doing the diagnosis for me that lead to my patch! |
string- and unicode- ndarrays followed different code paths for
int(a)vsa.__int__()andfloat(a)vs.a.__float(). Implement anb_intandnb_floatto rectify this.Unfortunately setting
tp_as_numberbefore callingPyType_Readyhas the side-effect of filling allNULLnb_*slots with functions via themroinheritance path (pulling them fromPyGenericType_Type). String types should not have anb_multiplynor anb_addsince they conflict with thesq_repeatandsq_concatfunctions from PyString_Type.Fixes issue #9972
TODO: document