[issue39689] struct and memoryview tests rely on undefined behavior (as revealed by clang 9)

Petr Viktorin report at bugs.python.org
Thu Mar 12 06:30:20 EDT 2020


Petr Viktorin <encukou at gmail.com> added the comment:

> So I vote for not handling incorrectly packed values and removing
"and any non-zero value will be True when unpacking" from the docs,
which does not seem to make any sense for _Bool.

I disagree. I don't think struct module's job is to be faithful to _Bool semantics.

Up to this point, "?" worked for bytes with "only 0 is false" semantics, in a reliable and documented way. I don't see a reason to let that continue.

You're right about trap representations, but IMO floats are much more tied to hardware (and serious users of float are aware of the pitfalls), while _Bool semantics are governed by the whims of the compiler.

Also, the "@" prefix is specifically documented to select native Byte order, Size, and Alignment; not how the bit-pattern is interpreted.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39689>
_______________________________________


More information about the Python-bugs-list mailing list