A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2011-August/112896.html below:

Add Py_RETURN_NOTIMPLEMENTED macro. Fixes #12724.

[Python-Dev] cpython: Add Py_RETURN_NOTIMPLEMENTED macro. Fixes #12724.Guido van Rossum guido at python.org
Tue Aug 16 01:52:43 CEST 2011
On Mon, Aug 15, 2011 at 4:39 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Tue, Aug 16, 2011 at 9:13 AM, Ethan Furman <ethan at 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.

I betcha if you extend your search to "return <variable>" preceded by
"INCREF(variable)" you'll find a whole lot more examples. :-)

-- 
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4