[Python-Dev] cpython: Add Py_RETURN_NOTIMPLEMENTED macro. Fixes #12724.

Raymond Hettinger raymond.hettinger at gmail.com
Mon Aug 15 14:46:12 CEST 2011


On Aug 15, 2011, at 5:35 AM, Nick Coghlan wrote:

> On Mon, Aug 15, 2011 at 10:17 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
>> AFAICT, often with True and False:
>> 
>>    x = (some condition) ? Py_True : Py_False;
>>    Py_INCREF(x);
>>    return x;
> 
> And that's an idiom that works better with a Py_RETURN macro than it
> would separate macros:
> 
> Py_RETURN(cond ? Py_True : Py_False);
> 
> OK, I'm persuaded that "Py_RETURN(Py_NotImplemented);" would be a
> better way to handle this change: +1

I don't think that is worth it.
There is some value to keeping the API consistent with the style that has been used in the past.
So, I vote for Py_RETURN_NOTIMPLEMENTED.  There's no real need to factor this any further.
It's not hard and not important enough to introduce a new variation on return macros.
Adding another return style makes the C API harder to learn and remember.
If we we're starting from scratch, Py_RETURN(obj) would make sense.
But we're not starting from scratch, so we should stick with the precedents.


Raymond


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110815/18199ced/attachment.html>


More information about the Python-Dev mailing list