From: Mark Dickinson Date: Sun, 18 Jul 2010 07:29:02 +0000 (+0000) Subject: Issue #9277: Struct module: standard bool packing was incorrect if X-Git-Tag: v3.2a1~179 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eff5d8594b817e5e101cf22b1af901d89363f70a;p=thirdparty%2FPython%2Fcpython.git Issue #9277: Struct module: standard bool packing was incorrect if char is unsigned. Thanks Stefan Krah for the patch. --- diff --git a/Modules/_struct.c b/Modules/_struct.c index b5f18a96adb2..d55ce0f60d50 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -867,11 +867,11 @@ bp_double(char *p, PyObject *v, const formatdef *f) static int bp_bool(char *p, PyObject *v, const formatdef *f) { - char y; + int y; y = PyObject_IsTrue(v); if (y < 0) return -1; - memcpy(p, (char *)&y, sizeof y); + *p = (char)y; return 0; }