[New-bugs-announce] [issue12724] Add Py_RETURN_NOTIMPLEMENTED

Brian Curtin report at bugs.python.org
Thu Aug 11 02:40:37 CEST 2011

New submission from Brian Curtin <brian at python.org>:

Would anyone be opposed to adding the following simple macro, which would be the same as the one we have for Py_RETURN_NONE. I recently found myself doing the Py_INCREF/return dance several times and ended up leaving an incref out in a few spots, which the macro form nicely handles.

diff --git a/Include/object.h b/Include/object.h
--- a/Include/object.h
+++ b/Include/object.h
@@ -792,6 +792,10 @@
 PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
 #define Py_NotImplemented (&_Py_NotImplementedStruct)

+/* Macro for returning Py_NotImplemented from a function */
+    return Py_INCREF(Py_NotImplemented), Py_NotImplemented
 /* Rich comparison opcodes */
 #define Py_LT 0
 #define Py_LE 1

If this is fine, I can also take care of making the replacements, of which there are apparently 55.

assignee: brian.curtin
components: None
keywords: needs review, patch
messages: 141886
nosy: brian.curtin
priority: normal
severity: normal
stage: patch review
status: open
type: feature request
versions: Python 3.3

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list