]> granicus.if.org Git - python/commitdiff
Merged revisions 82941 via svnmerge from
authorMark Dickinson <dickinsm@gmail.com>
Sun, 18 Jul 2010 07:42:29 +0000 (07:42 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Sun, 18 Jul 2010 07:42:29 +0000 (07:42 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r82941 | mark.dickinson | 2010-07-18 08:29:02 +0100 (Sun, 18 Jul 2010) | 3 lines

  Issue #9277: Struct module: standard bool packing was incorrect if
  char is unsigned.  Thanks Stefan Krah for the patch.
........

Modules/_struct.c

index ba8a8ed979e24b82d670c483902bd6ba3ec7c61e..c1db286b051ee806fdfb7a918d9af1df0e75e3c0 100644 (file)
@@ -856,11 +856,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;
 }