On Tue, Aug 16, 2011 at 9:13 AM, Ethan Furman <et...@stoneleaf.us> wrote:
> Barry Warsaw wrote:
>> So I'd opt for #1, unless we can agree on a better color for the bikeshed.
>
> My apologies if this is just noise, but are there RETURN macros that don't
> do an INCREF?

No, Py_RETURN_NONE is the only previous example, and it was added to
simplify the very common idiom of:

    Py_INCREF(Py_None);
    return Py_None;

It was added originally because it helped to avoid *two* common bugs:

  return Py_None; # segfault waiting to happen

  return NULL; # Just plain wrong, but not picked up until tests are
run and hence irritating

I'd say NotImplemented is the second most common instance of that kind
of direct incref-and-return (since operator methods need to return it
to correctly support type coercion), although, as Antoine noted,
Py_True and Py_False would be up there as well.

Cheers,
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