Message363924
> our unittest assuming that b'\xf0' should be true when interpreted as a bool is wrong.
> just get rid of that value from the loop in the test?
That could be the proper thing to do, but it does make it easy to invoke C undefined behavior from Python code. AFAIK, it would be the only such place in the struct module.
So, I'd like to assume and assert/test that sizeof(_Bool) is 1 and the false bit-pattern is (char)0, and with that, just use `PyBool_FromLong((_Bool)*p != 0)`.
> maybe we should be raising an error if the bytes are not a valid platform _Bool pattern?
That's quite hard to test for.
Also, on all current supported platforms, the patterns for bool and char 0 and 1 are the same. I don't see this being different elsewhere, but if there ever is a such a platform, let the test catch the broken assumption. |
|
Date |
User |
Action |
Args |
2020-03-11 14:41:49 | petr.viktorin | set | recipients:
+ petr.viktorin, gregory.p.smith, mark.dickinson, vstinner, benjamin.peterson, meador.inge, cstratak, ammar2 |
2020-03-11 14:41:49 | petr.viktorin | set | messageid: <1583937709.13.0.269433347234.issue39689@roundup.psfhosted.org> |
2020-03-11 14:41:49 | petr.viktorin | link | issue39689 messages |
2020-03-11 14:41:49 | petr.viktorin | create | |
|