Message347261
>>> b'\407'
b'\x07'
>>> ord(b'\407')
7
This is the object structure passed to builtin_ord():
(lldb) p *((PyBytesObject *)(c))
(PyBytesObject) $19 = {
ob_base = {
ob_base = {
ob_refcnt = 4
ob_type = 0x00000001003cb0b0
}
ob_size = 1
}
ob_shash = 8685212186264880044
ob_sval = {
[0] = '\a'
}
}
If two bytes were stored (0x107), I would expect ob_sval[0] to be 7 ('\a') and ob_sval[1] to be 1 on a little endian system, but ob_sval[1] is 0:
(lldb) p (long)(unsigned char) (((PyBytesObject *)(c))->ob_sval[0])
(long) $23 = 7
(lldb) p (long)(unsigned char) (((PyBytesObject *)(c))->ob_sval[1])
(long) $24 = 0
This means the truncation to a single byte is happening when the byte string object is created. |
|
Date |
User |
Action |
Args |
2019-07-04 08:07:50 | Jeffrey.Kintscher | set | recipients:
+ Jeffrey.Kintscher, terry.reedy, ezio.melotti, mrabarnett, serhiy.storchaka, bup |
2019-07-04 08:07:50 | Jeffrey.Kintscher | set | messageid: <1562227670.83.0.0849872417261.issue37367@roundup.psfhosted.org> |
2019-07-04 08:07:50 | Jeffrey.Kintscher | link | issue37367 messages |
2019-07-04 08:07:50 | Jeffrey.Kintscher | create | |
|