Petr Viktorin <encu...@gmail.com> added the comment:

> > > maybe we should be raising an error if the bytes are not a valid platform 
> > > _Bool pattern?
> > 
> > That's quite hard to test for.
> 
> How so? We just make the same assumption you're making that true = b'\x01' 
> and false = NUL.

Right, with that assumption, it's not that hard. And it becomes a test-only 
assumption, which is great!

But, I'm still not convinced this would be a good fix. The current struct 
documentation is consistent with *casting* char to _Bool, rather than doing the 
memcpy and reinterpreting as _Bool. The memcpy makes sense for larget types, 
but not so much for _Bool.

(Certainly, the docs' assertion that "the conversion between C and Python 
values should be obvious given their types" is not true here...)

----------

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

Reply via email to