New submission from Georg Brandl <ge...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue6239>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to