[New-bugs-announce] [issue24789] ctypes doc string

David W. Lambert report at bugs.python.org
Tue Aug 4 22:22:18 CEST 2015


New submission from David W. Lambert:

doc string suggests str is a valid init argument.  The code strongly discourages this.

ctypes.create_string_buffer

def create_string_buffer(init, size=None):
    """create_string_buffer(aBytes) -> character array
    create_string_buffer(anInteger) -> character array
    create_string_buffer(aString, anInteger) -> character array
    """
    if isinstance(init, bytes):
        if size is None:
            size = len(init)+1
        buftype = c_char * size
        buf = buftype()
        buf.value = init
        return buf
    elif isinstance(init, int):
        buftype = c_char * init
        buf = buftype()
        return buf
    raise TypeError(init)

----------
components: ctypes
messages: 247998
nosy: LambertDW
priority: normal
severity: normal
status: open
title: ctypes doc string
versions: Python 3.4

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


More information about the New-bugs-announce mailing list