Uh oh!
There was an error while loading. Please reload this page.
gh-112636: remove check for float subclasses without nb_float - #112637
gh-112636: remove check for float subclasses without nb_float#112637skirpichev wants to merge 4 commits into
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
skirpichev
commented
Sep 27, 2024
CC @vstinner, does it make sense for you? |
vstinner
commented
Sep 27, 2024
I don't understand the example. float(a) does now return XXX? Or does it print XXX? Which part of the code prints XXX? |
skirpichev
commented
Sep 28, 2024
Ah, that was just a debug print from the removed (by this pr) code. I've added a diff to description. The point is that to trigger that code - you must explicitly set nb_float field in the derived class to NULL. But in this way we can break everything! Can't you set nb_add to NULL in a float subclass? Easy! But CPython has enough code, which assuming that float subclasses have working arithmetic dunder methods. |
vstinner
commented
Sep 30, 2024
What is the behavior on this |
skirpichev
commented
Oct 1, 2024
It fails with TypeError (after you run first
Yes, because |
vstinner
left a comment
There was a problem hiding this comment.
This change is a backward incompatible change. You should document it in a NEWS entry.
serhiy-storchaka
commented
Oct 1, 2024
Sorry, but I now think that we should rather return a fallback for integers. |
skirpichev
commented
Oct 1, 2024
Ok, I did. News entry was missed just as in 31a6554 (dropped similar check in PyNumber_Long).
But why?! Should we check on same ground that an int subtype has nb_add field set? |
serhiy-storchaka
commented
Oct 1, 2024
Because |
skirpichev
commented
Oct 1, 2024
In same way we can recover in case when float subtype sets e.g. nb_negative to |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Victor Stinner <vstinner@python.org>
skirpichev
commented
Oct 7, 2024
There is a difference, if nb_int is set to Lines 1403 to 1405 in 31516c9 and Lines 1446 to 1448 in 31516c9 I still think we shouldn't keep workarounds for broken subtypes. But if so, at least the nb_int workaround shouldn't be restored. |
skirpichev
commented
Nov 2, 2024
Ok, I'm closing this. |
This condition could be triggered only in very special scenario, if users code explicitly override inherited
nb_floatvalue and set it toNULL: