Issue #1445: Fix a SystemError when accessing the `cell_contents`

attribute of an empty cell object.  Now a ValueError is raised.
This commit is contained in:
Amaury Forgeot d'Arc 2007-11-24 13:44:17 +00:00
parent 6dae85f409
commit ce7d10ccc4
3 changed files with 21 additions and 1 deletions

View file

@ -89,7 +89,12 @@ cell_clear(PyCellObject *op)
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;
}