New submission from Weihong Guan:

According to the doc:

For the '?' format character, the return value is either True or False. When 
packing, the truth value of the argument object is used. Either 0 or 1 in the 
native or standard bool representation will be packed, and any non-zero value 
will be True when unpacking.

But it behaves more like & 1 operation. so False for even value, and True for 
odd value.

unpack fmt '?H' should reqiure buff of length 3, same as 'H?', not 4.

----------
components: ctypes
files: Screen Shot 2016-10-06 at 20.59.43.png
messages: 278192
nosy: Weihong Guan
priority: normal
severity: normal
status: open
title: struct.unpack of Bool
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file44987/Screen Shot 2016-10-06 at 
20.59.43.png

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28377>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to