[New-bugs-announce] [issue17380] initproc return value is unclear

Zbyszek Jędrzejewski-Szmek report at bugs.python.org
Thu Mar 7 18:12:17 CET 2013


New submission from Zbyszek Jędrzejewski-Szmek:

initproc is declared to return an int, but what returned values mean is not documented. Noddy_init in http://docs.python.org/3/extending/newtypes.html?highlight=initproc#adding-data-and-methods-to-the-basic-example can be seen to return 0 on success and -1 on error, but that's about it.

Also, when I wrote a function which return 1 on error, on every second invocation the exception would be ignored:
static int Reader_init(Reader *self, PyObject *args, PyObject *keywds)
{
    ...
    if (flags && path) {
            PyErr_SetString(PyExc_ValueError, "cannot use both flags and path");
            return 1;
    }
    ...
}

>>> obj(123, '/tmp')
>>> obj(123, '/tmp')
...
ValueError
>>> obj(123, '/tmp')
>>> obj(123, '/tmp')
...
ValueError

I'm not sure how to interpret this since I couldn't find the documentation for the expected value.

----------
assignee: docs at python
components: Documentation, Extension Modules
messages: 183689
nosy: docs at python, zbysz
priority: normal
severity: normal
status: open
title: initproc return value is unclear
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4

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


More information about the New-bugs-announce mailing list