[Python-checkins] r82945 - in python/branches/release27-maint: Misc/NEWS Modules/_struct.c

mark.dickinson python-checkins at python.org
Sun Jul 18 09:55:55 CEST 2010


Author: mark.dickinson
Date: Sun Jul 18 09:55:55 2010
New Revision: 82945

Log:
Merged revisions 82941,82943 via svnmerge from 
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.
........


Modified:
   python/branches/release27-maint/   (props changed)
   python/branches/release27-maint/Misc/NEWS
   python/branches/release27-maint/Modules/_struct.c

Modified: python/branches/release27-maint/Misc/NEWS
==============================================================================
--- python/branches/release27-maint/Misc/NEWS	(original)
+++ python/branches/release27-maint/Misc/NEWS	Sun Jul 18 09:55:55 2010
@@ -44,6 +44,11 @@
 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
 -----
 

Modified: python/branches/release27-maint/Modules/_struct.c
==============================================================================
--- python/branches/release27-maint/Modules/_struct.c	(original)
+++ python/branches/release27-maint/Modules/_struct.c	Sun Jul 18 09:55:55 2010
@@ -912,11 +912,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;
 }
 


More information about the Python-checkins mailing list