-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-132775: Add _PyCode_Returns() #132981
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
gh-132775: Add _PyCode_Returns() #132981
Conversation
I think this name is confusing because a function returning |
Objects/codeobject.c
Outdated
Py_ssize_t len = Py_SIZE(co); | ||
for (int i = 0; i < len; i++) { | ||
_Py_CODEUNIT inst = _Py_GetBaseCodeUnit(co, i); | ||
if (inst.op.code == RETURN_VALUE) { |
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.
In the past we also had RETURN_CONST
and we might have something like that in the future, so I think we should make this more robust. Perhaps add a macro in Include/internal/pycore_opcode_utils.h (say IS_RETURN_OPCODE
). Also use this new macro in basicblock_returns
in flowgraph.c
.
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.
done
The function indicates whether or not the function has a return statement.
This is used by a later change related treating some functions like scripts.