[issue8161] inconsistency behavior in ctypes.c_char_p dereferencing

Irit Katriel report at bugs.python.org
Mon Dec 6 13:36:08 EST 2021


Irit Katriel <iritkatriel at gmail.com> added the comment:

On 3.11 I'm not getting str for the second expression, I get an empty bytes object:


>>> import ctypes
>>> class T(ctypes.Structure):
...     _fields_ = (
...             ('member', ctypes.c_char * 16),
...     )
... 
>>> print('%r'%((ctypes.c_char * 16)()[:]))
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>>> print('%r'%(T().member[:]))
b''

----------
nosy: +iritkatriel
status: open -> pending

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


More information about the Python-bugs-list mailing list