gh-103509: PEP 697 -- Limited C API for Extending Opaque Types (GH-103511)

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
Petr Viktorin 2023-05-04 09:56:53 +02:00 committed by GitHub
parent 35d273825a
commit cd9a56c2b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 970 additions and 19 deletions

View file

@ -8,6 +8,12 @@ PyObject *
PyMember_GetOne(const char *obj_addr, PyMemberDef *l)
{
PyObject *v;
if (l->flags & Py_RELATIVE_OFFSET) {
PyErr_SetString(
PyExc_SystemError,
"PyMember_GetOne used with Py_RELATIVE_OFFSET");
return NULL;
}
const char* addr = obj_addr + l->offset;
switch (l->type) {
@ -103,6 +109,12 @@ int
PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
{
PyObject *oldv;
if (l->flags & Py_RELATIVE_OFFSET) {
PyErr_SetString(
PyExc_SystemError,
"PyMember_SetOne used with Py_RELATIVE_OFFSET");
return -1;
}
addr += l->offset;