diff options
| -rw-r--r-- | Misc/NEWS | 5 | ||||
| -rw-r--r-- | Modules/_struct.c | 4 |
2 files changed, 7 insertions, 2 deletions
@@ -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 diff --git a/Modules/_struct.c b/Modules/_struct.c index b997d51..936e8af 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -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; } |
