diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_struct.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c index f629817..ba8a8ed 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -580,9 +580,13 @@ np_ulonglong(char *p, PyObject *v, const formatdef *f) static int np_bool(char *p, PyObject *v, const formatdef *f) { - BOOL_TYPE y; + int y; + BOOL_TYPE x; y = PyObject_IsTrue(v); - memcpy(p, (char *)&y, sizeof y); + if (y < 0) + return -1; + x = y; + memcpy(p, (char *)&x, sizeof x); return 0; } @@ -854,6 +858,8 @@ bp_bool(char *p, PyObject *v, const formatdef *f) { char y; y = PyObject_IsTrue(v); + if (y < 0) + return -1; memcpy(p, (char *)&y, sizeof y); return 0; } |