[Python-checkins] r45964 - in python/trunk: Doc/lib/libexcs.tex Lib/mailbox.py Lib/tempfile.py Misc/NEWS PC/errmap.h PC/errmap.mak PC/generrmap.c Python/exceptions.c

"Martin v. Löwis" martin at v.loewis.de
Tue May 16 08:15:10 CEST 2006


Neal Norwitz wrote:
>> +       /* Could not set errno. */
>> +       Py_XDECREF(o_errcode);
>> +       Py_DECREF(self);
>> +       Py_DECREF(result);
>> +       return NULL;
>> +}
> 
> self needs an XDECREF.

Actually, self is a borrowed reference, so it shouldn't get
decref'ed at all.

> Doesn't repr need to be DECREF'd here?

No: it's XDECREFed immediately when the tuple or fmt allocation failed.
Then, the reference moves into the tuple, and tuple deallocation will
also free repr.

> You could use PyTuple_Pack() insead of _New() and SET_ITEM (above and
> below).  It would be a bit shorter I think.

With some restructuring, it is indeed shorter. This code was cut-n-paste
from EnvironmentError__str__.

>> +static
>> +PyMethodDef WindowsError_methods[] = {
>> +    {"__init__", WindowsError__init__, METH_VARARGS},
>> +    {"__str__", WindowsError__str__, METH_VARARGS},
>> +    {NULL, NULL}
>> +};
> 
> You could use METH_O for __str__.

Sure; this requires changes to most other __str__ functions as they
call each other. I changed them all.

All fixed in 46003

Regards,
Martin



More information about the Python-checkins mailing list