GeezerVison is showing github.com — gh-132908: check the return type of isnormal() and issubnormal() by picnixz · Pull Request #136039 · python/cpython
Conversation
picnixz
commented
Jun 27, 2025
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
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 signbit but in C++, it returns a bool instead of just an integer [on some implementations it gives the power of 2 representing the sign bit].
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
That's why I don't sure we should add such checks.
Oh! Ok makes sense. Let's not burden the already existing tests. I've added it in signbit because signbit may return the corresponding power-of-two if there is a sign bit. But I think it's the only one that is not named "isXXX()" and that returns a boolean.
But it's up to you. BTW, probably you can remove comments - we have documentation, right?
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 is prefix but won't merge this one.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@skirpichev Btw, do you remember if we have an issue about positional-only arguments in math.* ? all functions are positional-only but I don't remember what we decided.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
do you remember if we have an issue about positional-only arguments in math.* ? all functions are positional-only but I don't remember what we decided.
@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.)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|