[docs] [issue13840] create_string_buffer rejects str init_or_size parameter

Meador Inge report at bugs.python.org
Wed Jan 25 04:14:26 CET 2012

Meador Inge <meadori at gmail.com> added the comment:

The 'create_unicode_buffer' docs are currently wrong too:

If the first parameter is a bytes object, it is converted into an 
unicode string according to ctypes conversion rules.

>>> ctypes.create_unicode_buffer(b'foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/meadori/src/python/cpython/Lib/ctypes/__init__.py", line 294, in create_unicode_buffer
    buf.value = init
TypeError: unicode string expected instead of bytes instance

The attached patch fixes the documentation and exception messages.

Although, it might be more friendly to implement things according to
the current docs (i.e. do the conversions).

components: +ctypes
keywords: +patch
stage:  -> patch review
versions: +Python 3.3
Added file: http://bugs.python.org/file24319/issue13840.patch

Python tracker <report at bugs.python.org>

More information about the docs mailing list