[Python-Dev] Re: tp_clear return value (original) (raw)

Neil Schemenauer nas@python.ca
Wed, 9 Apr 2003 14:41:04 -0700


"Martin v. L?wis" wrote:

Neil Schemenauer wrote: >In retrospect, I think both tptraverse and tpclear should have >returned "void".

While this is true for tpclear, tptraverse is actually more general. gc.getreferrers uses tptraverse, for something other than collection.

Could the visit procedure keep track of errors? Something like:

struct result {
    int error; /* true if an error occured while traversing */
    /* other results */
}

static void
myvisit(PyObject* obj, struct result *r)
{
    if (!r->error) {
        <do stuff, set r->error of error occurs>
    }
}