Sorry, something went wrong.
| { | ||
| PyObject *code = PyFunction_GetCode(func); | ||
| if (code != NULL) { | ||
| Py_INCREF(code); |
There was a problem hiding this comment.
Should this Py_INCREF be here? Shouldn't callee do this? 🤔
Without it I have this error:
Sorry, something went wrong.
There was a problem hiding this comment.
Cc: @markshannon as it pertains to code objects.
Sorry, something went wrong.
There was a problem hiding this comment.
I think this is correct, PyFunction_GetCode is documented as returning a borrowed ref: https://docs.python.org/3/c-api/function.html#c.PyFunction_GetCode
Sorry, something went wrong.
|
Thanks @sobolevn for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Sorry, something went wrong.
|
Sorry, @sobolevn and @JelleZijlstra, I could not cleanly backport this to 3.11 due to a conflict. |
Sorry, something went wrong.
|
GH-98317 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
In the next PRs I will cover PyFunction_* methods with setters.