]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #9277: Struct module: standard bool packing was incorrect if
authorMark Dickinson <dickinsm@gmail.com>
Sun, 18 Jul 2010 07:29:02 +0000 (07:29 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Sun, 18 Jul 2010 07:29:02 +0000 (07:29 +0000)
char is unsigned.  Thanks Stefan Krah for the patch.

Modules/_struct.c

index b5f18a96adb22eaee448af7a0a360dd05e9c661b..d55ce0f60d506d9440e486672c2b4673e687f4fa 100644 (file)
@@ -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;
 }