mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
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:
parent
35d273825a
commit
cd9a56c2b0
30 changed files with 970 additions and 19 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue