summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-07-07 18:54:59 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-07-07 18:54:59 (GMT)
commitde73c4587f665bdbf748715461691e9584f30c0f (patch)
treeb60e603250af75b81fc6c6b2b2c79701248ae947 /Modules
parente789016a70c161829627bf7497238f2d52b4b004 (diff)
downloadcpython-de73c4587f665bdbf748715461691e9584f30c0f.zip
cpython-de73c4587f665bdbf748715461691e9584f30c0f.tar.gz
cpython-de73c4587f665bdbf748715461691e9584f30c0f.tar.bz2
don't ignore exceptions from PyObject_IsTrue
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_struct.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c
index e1d016b..b5f18a9 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -591,9 +591,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;
}
@@ -865,6 +869,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;
}