diff options
Diffstat (limited to 'Python/structmember.c')
-rw-r--r-- | Python/structmember.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Python/structmember.c b/Python/structmember.c index 38fc1be..d230590 100644 --- a/Python/structmember.c +++ b/Python/structmember.c @@ -61,6 +61,9 @@ PyMember_GetOne(const char *addr, PyMemberDef *l) } addr += l->offset; switch (l->type) { + case T_BOOL: + v = PyBool_FromLong(*(char*)addr); + break; case T_BYTE: v = PyInt_FromLong(*(char*)addr); break; @@ -183,6 +186,18 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) } addr += l->offset; switch (l->type) { + case T_BOOL:{ + if (!PyBool_Check(v)) { + PyErr_SetString(PyExc_TypeError, + "attribute value type must be bool"); + return -1; + } + if (v == Py_True) + *(char*)addr = (char) 1; + else + *(char*)addr = (char) 0; + break; + } case T_BYTE:{ long long_val = PyInt_AsLong(v); if ((long_val == -1) && PyErr_Occurred()) |