gh-132908: check the return type of isnormal() and issubnormal()#136039
gh-132908: check the return type of isnormal() and issubnormal()#136039picnixz wants to merge 1 commit intopython:mainfrom
Conversation
skirpichev
left a comment
There was a problem hiding this comment.
Looks good, but we don't have similar checks for other predicates, e.g. isfinite(). That's why I don't sure we should add such checks.
But it's up to you. BTW, probably you can remove comments - we have documentation, right?
Oh! Ok makes sense. Let's not burden the already existing tests. I've added it in
Right. I actually wanted to add a comment in the tests in case we change the return value for some reason (it could serve as a regression test as well). I don't want to burden the online docs with those implementation details (in C++ for instance, it's a boolean that is returned, so depending on the page of cppreference you land, you may be like "why are they explaining this?"). Sorry for the noise! I'll keep the check in the signbit PR because of the lack of the |
|
@skirpichev Btw, do you remember if we have an issue about positional-only arguments in |
@picnixz, I'm not sure we have an issue about this. Perhaps, you are about this pr: #131886 ? In similar way we could change signatures in the math module. The cost is a small regression in processing arguments. (Perhaps, it could be solved.) |
I've actually stumbled upon the isnormal() C11 requirements (which I assume are the same as issubnormal() ones but I don't have a C23 copy) and I think we can add those checks (I first thought about returning the integer value given by
signbitbut in C++, it returns a bool instead of just an integer [on some implementations it gives the power of 2 representing the sign bit].