This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ctypes doc string
Type: behavior Stage: resolved
Components: ctypes, Documentation Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: LambertDW, berker.peksag, docs@python, eryksun, ezio.melotti, matheus.v.portela, python-dev
Priority: normal Keywords: easy, patch

Created on 2015-08-04 20:22 by LambertDW, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue24789_ctypes_doc_string.patch matheus.v.portela, 2015-08-28 00:06 review
Messages (5)
msg247998 - (view) Author: David W. Lambert (LambertDW) Date: 2015-08-04 20:22
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)
msg248002 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2015-08-04 20:37
That's a vestige of the 2.x docs. For 3.x it should be "create_string_buffer(aBytes, anInteger)".
msg249270 - (view) Author: Matheus Vieira Portela (matheus.v.portela) * Date: 2015-08-28 00:06
Updated create_string_buffer docstring to "create_string_buffer(aBytes, anInteger) -> character array".
msg257829 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-01-09 14:09
New changeset 1753a28acad4 by Ezio Melotti in branch '3.5':
#24789: fix docstring of ctypes.create_string_buffer.  Patch by Matheus Vieira Portela.
https://hg.python.org/cpython/rev/1753a28acad4

New changeset 57964ca3ce0f by Ezio Melotti in branch 'default':
#24789: merge with 3.5.
https://hg.python.org/cpython/rev/57964ca3ce0f
msg257830 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2016-01-09 14:11
Fixed, thanks for the patch!
History
Date User Action Args
2022-04-11 14:58:19adminsetgithub: 68977
2016-01-09 14:11:29ezio.melottisetstatus: open -> closed

versions: - Python 3.4
nosy: + ezio.melotti

messages: + msg257830
resolution: fixed
stage: needs patch -> resolved
2016-01-09 14:09:38python-devsetnosy: + python-dev
messages: + msg257829
2015-08-28 00:06:39matheus.v.portelasetfiles: + issue24789_ctypes_doc_string.patch

nosy: + matheus.v.portela
messages: + msg249270

keywords: + patch
2015-08-25 04:26:23berker.peksagsetkeywords: + easy
nosy: + berker.peksag

type: behavior
stage: needs patch
2015-08-04 20:37:44eryksunsetversions: + Python 3.5, Python 3.6
nosy: + docs@python, eryksun

messages: + msg248002

assignee: docs@python
components: + Documentation
2015-08-04 20:22:18LambertDWcreate