This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Bug in struct.pack
Type: behavior Stage: resolved
Components: Versions: Python 3.9
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: steven.daprano, terje.myklebust123
Priority: normal Keywords:

Created on 2021-11-11 10:32 by terje.myklebust123, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg406150 - (view) Author: Terje Myklebust (terje.myklebust123) Date: 2021-11-11 10:32
>>> struct.pack("i", 119) 

"w" in a binary value?

>>> struct.pack("I", 116) 

"t" in a binary value?
msg406153 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2021-11-11 10:43
The behaviour is correct. You have tripped over the ASCII representation of bytes. In ASCII, 119 (or in hex, 0x77) is displayed as 'w'.

>>> b'\x77\x00\x00\x00'
Date User Action Args
2022-04-11 14:59:52adminsetgithub: 89940
2021-11-11 10:43:12steven.dapranosetstatus: open -> closed

nosy: + steven.daprano
messages: + msg406153

resolution: not a bug
stage: resolved
2021-11-11 10:32:18terje.myklebust123create