FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-132775: Add _PyCode_ReturnsOnlyNone() by ericsnowcurrently · Pull Request #132981 · python/cpython · GitHub

/ cpython Public

gh-132775: Add _PyCode_ReturnsOnlyNone() - #132981

Merged
ericsnowcurrently merged 5 commits into
python:mainfrom
ericsnowcurrently:add-pycode-returns
Apr 29, 2025
Merged

gh-132775: Add _PyCode_ReturnsOnlyNone()#132981
ericsnowcurrently merged 5 commits into
python:mainfrom
ericsnowcurrently:add-pycode-returns

Conversation

ericsnowcurrently commented Apr 25, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

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.

ericsnowcurrently changed the title Add _PyCode_Returns() gh-132775: Add _PyCode_Returns() Apr 25, 2025

Copy link
Copy Markdown
Member

I think this name is confusing because a function returning None also returns.

Comment thread 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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

done

ericsnowcurrently merged commit 96a7fb9 into python:main Apr 29, 2025
ericsnowcurrently deleted the add-pycode-returns branch April 29, 2025 02:12
AA-Turner changed the title gh-132775: Add _PyCode_Returns() gh-132775: Add _PyCode_ReturnsOnlyNone() May 2, 2025
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL