-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
gh-139778: Assertion fix in code_returns_only_none
#139779
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
base: main
Are you sure you want to change the base?
gh-139778: Assertion fix in code_returns_only_none
#139779
Conversation
I've removed incorrect assertion, reorganize a little and update code comments. |
Objects/codeobject.c
Outdated
|
||
// That means there must be | ||
// an explicit return (non-None), or it only raises. | ||
// The last instruction mostly either returns or raises. |
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.
What about raises? Do you need to handle it?
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.
No, raises can't change return value of a function. There was only one incorrect assumption that each function should end with either return
or raise
if there's no None
in the list of constants. But we can preserve old checking, because we only need to find return
statement.
} | ||
// It must only raise. | ||
|
||
none_index = -1; |
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 believe you have to add comments here or below where you use this 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.
What kind of comments?
CC @picnixz. |
code_returns_only_none
#139778