-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
PEP 697 -- Limited C API for Extending Opaque Types #103509
Comments
…3511) Co-authored-by: Oleg Iarygin <[email protected]> Co-authored-by: Erlend E. Aasland <[email protected]>
Erlend mentioned that he'll have ideas for follow-up PRs, so keeping the issue open. |
I'll just post my suggestion here instead of opening a PR. It kind of bothers me a bit that suggestion - diffdiff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 171c76a59a..ad7b9c1ce4 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -4532,7 +4532,12 @@ void *
PyObject_GetTypeData(PyObject *obj, PyTypeObject *cls)
{
assert(PyObject_TypeCheck(obj, cls));
- return (char *)obj + _align_up(cls->tp_base->tp_basicsize);
+ void *ret = (char *)obj + _align_up(cls->tp_base->tp_basicsize);
+
+ /* This API is documented to raise an exception if it returns NULL.
+ * The current implementation, however, always succeeds. */
+ assert(ret != NULL);
+ return ret;
}
Py_ssize_t
@@ -4542,6 +4547,10 @@ PyType_GetTypeDataSize(PyTypeObject *cls)
if (result < 0) {
return 0;
}
+
+ /* This API is documented to raise an exception if it returns -1.
+ * The current implementation, however, always succeeds. */
+ assert(result >= 0);
return result;
} |
makes sense |
It doesn't bother me. We could add a comment for clarity, but I would word it as.
However, that's just repeating what's already in the docs... |
NP, it's not a deal-breaker for me. Let's just leave it as it is 🙂 |
PEP 697 was accepted and needs to be implemented.
Linked PRs
The text was updated successfully, but these errors were encountered: