| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -13,7 +13,11 @@ extern "C" { | |
|
|
||
| PyAPI_DATA(PyTypeObject) PyCFunction_Type; | ||
|
|
||
| #define PyCFunction_Check(op) (Py_IS_TYPE(op, &PyCFunction_Type) || (PyType_IsSubtype(Py_TYPE(op), &PyCFunction_Type))) | ||
| #define PyCFunction_CheckExact(op) Py_IS_TYPE(op, &PyCFunction_Type) | ||
| #define PyCFunction_Check(op) PyObject_TypeCheck(op, &PyCFunction_Type) | ||
|
|
||
| #define PyCMethod_CheckExact(op) Py_IS_TYPE(op, &PyCMethod_Type) | ||
| #define PyCMethod_Check(op) PyObject_TypeCheck(op, &PyCMethod_Type) | ||
|
Comment thread
Outdated
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityYou cannot add this macro to the limited C API, since PyCMethod_Type is not defined in the limited C API.
Sorry, something went wrong.
scoder reacted with thumbs up emoji
All reactions
|
||
|
|
||
| typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); | ||
| typedef PyObject *(*_PyCFunctionFast) (PyObject *, PyObject *const *, Py_ssize_t); | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Add PyCFunction_CheckExact() macro for exact type checks now that we allow subtypes of PyCFunction, | ||
|
Comment thread
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis NEWS entry belongs to C API category.
Sorry, something went wrong.
scoder reacted with thumbs up emoji
All reactions
|
||
| as well as PyCMethod_CheckExact() and PyCMethod_Check() for the new PyCMethod subtype. | ||
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI would prefer to exclude PyCFunction_CheckExact() from the limited C API.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI'm not so sure. We are changing the semantics of PyCFunction_Check() by adding a subtype that it covers. The macro is a part of the limited C-API and thus, the semantic change is a problem all by itself. Either we accept that, then we should add the "obvious" related CheckExact macro, also to the limited API. Or, we reject that change all together. I don't think the latter is an option, though.
Personally, I'd say, since it's a macro, it doesn't hurt, since it has no impact at all on the ABI. Everyone can safely copy and use that macro also on their side, so why not just add it?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI will not hold this PR just for that. We can should PyCFunction_CheckExact() as it is in Python 3.9, and revisit the issue later. I created https://bugs.python.org/issue40601 to explain my concern: I plan to work on that in Python 3.10, it's too late for Python 3.9.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityDo note that PyCMethod is a bit of a hack in that PyCFunction is still not an "acceptable base type". You can't subclasstype(print), but static types happen to bypass the Py_TPFLAGS_BASETYPE check. This is one more thing to be resolved if we want all types can become heap types.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.