[docs] [issue10058] Unclear PyString_AsStringAndSize return value

Nikolaus Rath report at bugs.python.org
Sun Oct 10 01:37:58 CEST 2010

New submission from Nikolaus Rath <Nikolaus at rath.org>:

http://docs.python.org/c-api/string.html says about the return value of AsStringAndSize:

"If length is NULL, the resulting buffer may not contain NUL characters; if it does, the function returns -1 and a TypeError is raised."

"If string is not a string object at all, PyString_AsStringAndSize() returns -1 and raises TypeError."

This makes me wonder what the return code is if a) the function succeeds and b) it encounteres some other problem (i.e. out of memory when it tries to encode a unicode string into its default encoding).

I guess that the return value is 0 on success and -1 on all errors, but it would be nice if the documentation would be clear about this.

assignee: docs at python
components: Documentation
messages: 118294
nosy: Nikratio, docs at python
priority: normal
severity: normal
status: open
title: Unclear PyString_AsStringAndSize return value
type: feature request
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the docs mailing list