Issue #1445: Fix a SystemError when accessing the ``cell_contents``
attribute of an empty cell object. Now a ValueError is raised.
diff --git a/Objects/cellobject.c b/Objects/cellobject.c
index 63322c1..dc684d5 100644
--- a/Objects/cellobject.c
+++ b/Objects/cellobject.c
@@ -89,7 +89,12 @@
static PyObject *
cell_get_contents(PyCellObject *op, void *closure)
{
- Py_XINCREF(op->ob_ref);
+ if (op->ob_ref == NULL)
+ {
+ PyErr_SetString(PyExc_ValueError, "Cell is empty");
+ return NULL;
+ }
+ Py_INCREF(op->ob_ref);
return op->ob_ref;
}