[issue6239] c_char_p return value returns string, not bytes

Georg Brandl report at bugs.python.org
Mon Jun 8 18:07:29 CEST 2009


New submission from Georg Brandl <georg at python.org>:

If you assign a function a restype of c_char_p, you get back a Unicode
string, but you should get a bytes object.

>>> from ctypes import *
>>> strchr = cdll['libc.so.6'].strchr
>>> strchr.restype = c_char_p
>>> strchr.argtypes = [c_char_p, c_char]
>>> strchr(b'abcde', b'd')
'de'

----------
assignee: theller
components: ctypes
messages: 89086
nosy: georg.brandl, theller
priority: critical
severity: normal
stage: needs patch
status: open
title: c_char_p return value returns string, not bytes
type: behavior
versions: Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6239>
_______________________________________


More information about the Python-bugs-list mailing list