[Python-Dev] cpython: Fix email post-commit review comments.

Nick Coghlan ncoghlan at gmail.com
Thu Apr 19 03:20:03 CEST 2012

On Thu, Apr 19, 2012 at 12:21 AM, Antoine Pitrou <solipsis at 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

> (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 :(


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list