GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-92154: Expose PyCode_GetCode in the C API by Fidget-Spinner · Pull Request #92168 · python/cpython Conversation
|
| PyCode_GetCode(PyObject *co) | ||
| { | ||
| if (!PyCode_Check(co)) { | ||
| PyErr_BadInternalCall(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I forgot if this or a TypeError is preferred for the C API (or no error setting at all?)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Use PyCode_GetCode(PyCodeObject *co) and then you won't need the check.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I would like to, but co_code was previously PyObject*, and I want this to be a drop-in replacement as far as possible.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Also I frankly have no clue if we need to update |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
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.
The reason will be displayed to describe this comment to others. Learn more.
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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I prepared PR python/pythoncapi-compat#34 to add the function to pythoncapi-compat. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[C-API] Add a function to access PyCodeObject.co_code in C
There was an error while loading. Please reload this page.