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.

Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to