Uh oh!
There was an error while loading. Please reload this page.
gh-92154: Expose PyCode_GetCode in the C API - #92168
Conversation
| PyCode_GetCode(PyObject *co) | ||
| { | ||
| if (!PyCode_Check(co)) { | ||
| PyErr_BadInternalCall(); |
There was a problem hiding this comment.
I forgot if this or a TypeError is preferred for the C API (or no error setting at all?)
There was a problem hiding this comment.
Use PyCode_GetCode(PyCodeObject *co) and then you won't need the check.
There was a problem hiding this comment.
I would like to, but co_code was previously PyObject*, and I want this to be a drop-in replacement as far as possible.
There was a problem hiding this comment.
PyErr_BadInternalCall() is fine, but I would even suggest replacing a runtime check with an assertion. The caller is responsible to pass the right type.
Fidget-Spinner
commented
May 2, 2022
Also I frankly have no clue if we need to update |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| PyCode_GetCode(PyObject *co) | ||
| { | ||
| if (!PyCode_Check(co)) { | ||
| PyErr_BadInternalCall(); |
There was a problem hiding this comment.
PyErr_BadInternalCall() is fine, but I would even suggest replacing a runtime check with an assertion. The caller is responsible to pass the right type.
vstinner
commented
May 3, 2022
Include/cpython/ is the API excluded from the limited C API and so excluded from the stable ABI: https://devguide.python.org/c-api/ Please don't add this function to the stable ABI yet. Let's wait for one Python release, and then see if it's stable or not. |
Uh oh!
There was an error while loading. Please reload this page.
vstinner
commented
May 3, 2022
I prepared PR python/pythoncapi-compat#34 to add the function to pythoncapi-compat. |
Fixes#92154.