[Python-checkins] cpython: Added notimplemented_dealloc for better error reporting

armin.ronacher python-checkins at python.org
Sat Oct 6 14:30:39 CEST 2012


http://hg.python.org/cpython/rev/75d3a783d728
changeset:   79513:75d3a783d728
user:        Armin Ronacher <armin.ronacher at active-4.com>
date:        Sat Oct 06 14:28:58 2012 +0200
summary:
  Added notimplemented_dealloc for better error reporting

files:
  Objects/object.c |  11 ++++++++++-
  1 files changed, 10 insertions(+), 1 deletions(-)


diff --git a/Objects/object.c b/Objects/object.c
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1524,12 +1524,21 @@
     Py_RETURN_NOTIMPLEMENTED;
 }
 
+static void
+notimplemented_dealloc(PyObject* ignore)
+{
+    /* This should never get called, but we also don't want to SEGV if
+     * we accidentally decref NotImplemented out of existence.
+     */
+    Py_FatalError("deallocating NotImplemented");
+}
+
 static PyTypeObject PyNotImplemented_Type = {
     PyVarObject_HEAD_INIT(&PyType_Type, 0)
     "NotImplementedType",
     0,
     0,
-    none_dealloc,       /*tp_dealloc*/ /*never called*/
+    notimplemented_dealloc,       /*tp_dealloc*/ /*never called*/
     0,                  /*tp_print*/
     0,                  /*tp_getattr*/
     0,                  /*tp_setattr*/

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list