summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-01-21 21:23:15 (GMT)
committerGeorg Brandl <georg@python.org>2008-01-21 21:23:15 (GMT)
commit32a3fb5ec95c9417c43344a80d9e09c8042ac66d (patch)
tree7ecc7556d326a3e4e873f52e7611ca41a122b680 /Python
parentf00b38e08ccdcb48e409df951454f91cec428c0e (diff)
downloadcpython-32a3fb5ec95c9417c43344a80d9e09c8042ac66d.zip
cpython-32a3fb5ec95c9417c43344a80d9e09c8042ac66d.tar.gz
cpython-32a3fb5ec95c9417c43344a80d9e09c8042ac66d.tar.bz2
Patch #1720595: add T_BOOL to the range of structmember types.
Patch by Angelo Mottola, reviewed by MvL, tests by me.
Diffstat (limited to 'Python')
-rw-r--r--Python/structmember.c15
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())