[issue22012] struct.unpack('?', '\x02') returns (False,) on Mac OSX

Ronald Oussoren report at bugs.python.org
Sun Jul 20 09:06:21 CEST 2014


Ronald Oussoren added the comment:

> On 19 jul. 2014, at 23:22, Mark Dickinson <report at bugs.python.org> wrote:
> 
> 
> Mark Dickinson added the comment:
> 
> The relevant piece of code in the struct module looks like this:
> 
> static PyObject *
> nu_bool(const char *p, const formatdef *f)
> {
>    BOOL_TYPE x;
>    memcpy((char *)&x, p, sizeof x);
>    return PyBool_FromLong(x != 0);
> }
> 
> Is it possible that BOOL_TYPE is a bitfield of length 1, and that clang is somehow making use of that fact?

I haven't found a definitive source yet, but it seems that the only valid values for _Bool, which BOOL_TYPE expands to, are 0 and 1.  Clang might make use of that restriction. 

Ronald

----------
title: struct.unpack('?', '\x02') returns (False,) when Python is built with clang -> struct.unpack('?', '\x02') returns (False,) on Mac OSX

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22012>
_______________________________________


More information about the Python-bugs-list mailing list