]> granicus.if.org Git - python/commitdiff
Merged revisions 82945 via svnmerge from
authorMark Dickinson <dickinsm@gmail.com>
Sun, 18 Jul 2010 08:01:37 +0000 (08:01 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Sun, 18 Jul 2010 08:01:37 +0000 (08:01 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/release27-maint

................
  r82945 | mark.dickinson | 2010-07-18 08:55:55 +0100 (Sun, 18 Jul 2010) | 14 lines

  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.
  ........
................

Misc/NEWS
Modules/_struct.c

index 0688d0b6ba750048353c08bab4974cd9824959ba..c324df36976c6152f60df77f1cae574afecaae0d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -302,6 +302,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.
+
 - Issue #7384: If the system readline library is linked against
   ncurses, do not link the readline module against ncursesw. The
   additional restriction of linking the readline and curses modules
index b997d51bd65ad2b3c69a3716e25556692b2ff4cc..936e8af043602cbe388dcbfd276c7f1e8575de11 100644 (file)
@@ -1013,9 +1013,9 @@ 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);
-    memcpy(p, (char *)&y, sizeof y);
+    *p = (char)y;
     return 0;
 }