Repository navigation
gh-92154: Expose PyCode_GetCode in the C API #92168
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
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Added the :c:func:`PyCode_GetCode` function. This function does the | ||
| equivalent of the Python code ``getattr(code_object, 'co_code')``. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1370,6 +1370,15 @@ _PyCode_GetCode(PyCodeObject *co) | |
| return code; | ||
| } | ||
|
|
||
| PyObject * | ||
| PyCode_GetCode(PyObject *co) | ||
| { | ||
| if (!PyCode_Check(co)) { | ||
| PyErr_BadInternalCall(); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot if this or a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to, but
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| return NULL; | ||
| } | ||
| return _PyCode_GetCode((PyCodeObject *)co); | ||
| } | ||
|
|
||
| /****************** | ||
| * PyCode_Type | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.