]> granicus.if.org Git - python/commitdiff
Merged revisions 82941,82943 via svnmerge from
authorMark Dickinson <dickinsm@gmail.com>
Sun, 18 Jul 2010 07:55:55 +0000 (07:55 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Sun, 18 Jul 2010 07:55:55 +0000 (07:55 +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.
........
  r82943 | mark.dickinson | 2010-07-18 08:48:20 +0100 (Sun, 18 Jul 2010) | 1 line

  Misc/NEWS entry for r82941.
........

Misc/NEWS
Modules/_struct.c

index 819a401172b472dd851504d9579df64f334dc3ba..ec857acde19045bfae030bc0064764a821d71a4a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -44,6 +44,11 @@ Library
 Extension Modules
 -----------------
 
+- Issue #9277: Fix bug in struct.pack for bools in standard mode
+  (e.g., struct.pack('>?')):  if conversion to bool raised an exception
+  then that exception wasn't properly propagated on machines where
+  char is unsigned.
+
 Build
 -----
 
index 52c5eeb1703f86b710b911c8906e071b04621684..f22c31cd2a021a482bfa148e83572f913a84e2ba 100644 (file)
@@ -912,11 +912,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;
 }