| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
This implements the current documentation somewhat pedantically: The '?' conversion code corresponds to the _Bool type defined by C99. If this type is not available, it is simulated using a char. In standard mode, it is always represented by one byte. We always have C99 now, so native mode always uses _Bool. When compiling with >>> from struct import *
>>> unpack("?", b"\x02")
/home/stefan/cpython/Modules/_struct.c:487:12: runtime error: load of value 2, which is not a valid value for type '_Bool'
(False,)This, however, should pass (and does after this patch): >>> unpack("<?", b"\x02")
(True,) |
Sorry, something went wrong.
There was a problem hiding this comment.
The docs currently say:
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.
So, if we do want change that and expose UB to Python, the docs need to change. IMO, this will need a news entry as well.
The docs also currently talk about the characters @=<>! only affecting byte order, size, and alignment. Will that need to be expanded?
Sorry, something went wrong.
|
When you're done making the requested changes, leave the comment: I have made the requested changes; please review again. |
Sorry, something went wrong.
|
Thanks @skrah for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Sorry, something went wrong.
|
Thanks @skrah for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
Sorry, something went wrong.
|
GH-19154 is a backport of this pull request to the 3.7 branch. |
Sorry, something went wrong.
|
GH-19155 is a backport of this pull request to the 3.8 branch. |
Sorry, something went wrong.
pythonGH-18969) (cherry picked from commit 472fc84) Co-authored-by: Stefan Krah <skrah@bytereef.org>
pythonGH-18969) (cherry picked from commit 472fc84) Co-authored-by: Stefan Krah <skrah@bytereef.org>
| Back | FazBrowse Home | New Git URL |
https://bugs.python.org/issue39689
Automerge-Triggered-By: @encukou