On Thu, Apr 19, 2012 at 12:21 AM, Antoine Pitrou <solip...@pitrou.net> wrote:
> I don't think INCREFs were necessary, actually.
> PyDict_SetItemString doesn't steal a reference.

Yes, I was tired when that checkin went by and my brain didn't
register that the function was otherwise using borrowed refs for name
and path, so it was also correct to use borrowed refs to Py_None.

I should have been less cryptic and written out my full question
"Should there be Py_INCREF's here?" rather than using the shorthand (i
genuinely wasn't sure at the time, but that wasn't clear from what I
wrote).

> (and here we see why reference-stealing APIs are a nuisance: because
> you never know in advance whether a function will steal a reference or
> not, and you have to read the docs for each and every C API call you
> make)

Yeah, it would have been nice if there was an explicit hint in the API
names when reference stealing was involved, but I guess it's far too
late now :(

Regards,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to