This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add Py_RETURN_NOTIMPLEMENTED
Type: enhancement Stage: patch review
Components: None Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brian.curtin Nosy List: benjamin.peterson, brian.curtin, python-dev
Priority: normal Keywords: needs review, patch

Created on 2011-08-11 00:40 by brian.curtin, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg141886 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2011-08-11 00:40
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 */
+#define Py_RETURN_NOTIMPLEMENTED \
+    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.
msg141888 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-08-11 00:58
+1
msg141891 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-08-11 01:34
New changeset 77a65b078852 by Brian Curtin in branch 'default':
Add Py_RETURN_NOTIMPLEMENTED macro. Fixes #12724.
http://hg.python.org/cpython/rev/77a65b078852

New changeset d0b0fcbb40db by Brian Curtin in branch 'default':
Replace Py_NotImplemented returns with the macro form Py_RETURN_NOTIMPLEMENTED.
http://hg.python.org/cpython/rev/d0b0fcbb40db

New changeset 3a6782f2a4a8 by Brian Curtin in branch 'default':
News item for #12724
http://hg.python.org/cpython/rev/3a6782f2a4a8
msg141907 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-08-11 14:41
New changeset e88362fb4950 by Brian Curtin in branch 'default':
Add doc for Py_RETURN_NOTIMPLEMENTED, added in #12724.
http://hg.python.org/cpython/rev/e88362fb4950
History
Date User Action Args
2022-04-11 14:57:20adminsetgithub: 56933
2011-08-11 14:41:59python-devsetmessages: + msg141907
2011-08-11 01:35:25brian.curtinsetstatus: open -> closed
resolution: fixed
2011-08-11 01:34:38python-devsetnosy: + python-dev
messages: + msg141891
2011-08-11 00:58:15benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg141888
2011-08-11 00:40:37brian.curtincreate