[issue13840] create_string_buffer rejects str init_or_size parameter

Vincent Pelletier report at bugs.python.org
Mon Jan 23 08:53:08 CET 2012


New submission from Vincent Pelletier <plr.vincent at gmail.com>:

ctypes.create_string_buffer documentation[1] says init_or_size parameter should accept a string. As of 3.2, it raises:
>>> import ctypes
>>> ctypes.create_string_buffer('foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.2/ctypes/__init__.py", line 59, in create_string_buffer
    buf.value = init
TypeError: str/bytes expected instead of str instance

It works fine as of 2.7 (and very probably any 2.x up to ctypes introduction):
>>> import ctypes
>>> ctypes.create_string_buffer('foo')
<ctypes.c_char_Array_4 object at 0x7fbdcb8b95f0>

[1] http://docs.python.org/py3k/library/ctypes.html#ctypes.create_string_buffer

Regards,
Vincent Pelletier

----------
components: ctypes
messages: 151800
nosy: vpelletier
priority: normal
severity: normal
status: open
title: create_string_buffer rejects str init_or_size parameter
type: behavior
versions: Python 3.2

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


More information about the Python-bugs-list mailing list