-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS #6030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d0f9597
Objects: Add an unused argument to METH_NOARGS functions
siddhesh 76d12b9
Python: Add an unused argument to METH_NOARGS functions
siddhesh b0be175
PC: Add or mark an unused argument to METH_NOARGS functions
siddhesh 3f968f5
Modules: Add an unused argument to METH_NOARGS functions
siddhesh 6cca1ec
Doc: Add an unused argument to METH_NOARGS functions
siddhesh e83b872
Add NEWS item for the internal METH_NOARGS changes
siddhesh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Modules: Add an unused argument to METH_NOARGS functions
METH_NOARGS functions need only a single argument but they are cast into a PyCFunction, which takes two arguments. This triggers an invalid function cast warning in gcc8 (unreleased as of now) due to the argument mismatch. Fix this by adding a dummy unused argument.
- Loading branch information
commit 3f968f570424e9ff1267c94e57dd9daf3bd75ff9
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
Explicit cast to
PyCFunction
at line 1590 is not needed.The same with other functions which exactly match the signature of
PyCFunction
.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.
I've kept the casts in place because we will eventually need it. To fully fix the warnings, the
ml_meth
type should be like so:PyObject *(*) (PyObject *, PyObject *, ...)
so that it matches with all of the allowed method types provided that there is an explicit cast in place. Right now I am not sure if I should change the
PyCFunction
type to that or to make a newPyCFunctionAny
just forml_meth
. Since we're on this topic, what do you think is the preferred change? I suppose both change API, but not in a completely incompatible way.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.
The casts are not needed if the signature matches
PyCFunction
. It is still needed if the function has typePyCFunctionWithKeywords
,PyNoArgsFunction
, etc. Removing unneeded casts will clean up the code and can prevent introducing new bugs when the signature be changed unintentionally.