diff Modules/_struct.c @ 63065:2683333755f3

Issue #9277: Struct module: standard bool packing was incorrect if char is unsigned. Thanks Stefan Krah for the patch.
author Mark Dickinson <dickinsm@gmail.com>
date Sun, 18 Jul 2010 07:29:02 +0000
parents f6266c459156
children 29ab536cfef6
line wrap: on
line diff
--- a/Modules/_struct.c	Sat Jul 17 22:50:45 2010 +0000
+++ b/Modules/_struct.c	Sun Jul 18 07:29:02 2010 +0000
@@ -867,11 +867,11 @@
 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;
 }