Stefan Behnel wrote:
> Dag Sverre Seljebotn wrote:
>> While ripping out the old temp system (yay!), I discovered the following
>> code in CEnumDefNode. I don't know much about the CPython API, but
>> there's no note in the docs that PyObject_SetAttrString eats a reference.
>>
>> Is this a leak? (It's using a local temporary variable which is not
>> refnannied)
>>
>> for item in self.entry.enum_values:
>> code.putln("%s = PyInt_FromLong(%s); %s" % (
>> temp,
>> item.cname,
>> code.error_goto_if_null(temp, item.pos)))
>> code.putln('if (__Pyx_SetAttrString(%s, "%s", %s) < 0)
>> %s' % (
>> Naming.module_cname,
>> item.name,
>> temp,
>> code.error_goto(item.pos)))
>> code.putln("%s = 0;" % temp)
>
> PyObject_SetAttr() maps to PyDict_SetItem(), which INCREFs the value. So we
> need to care about the reference ourselves here.
OK, this is now [1]. However, I don't know how to make a public enum and
am so unable to produce a testcode invoking the code, so someone who
knows how to actually make a public enum should follow this one up.
[1] http://trac.cython.org/cython_trac/ticket/270
--
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev