Exemplo n.º 1
0
static void
map_to_dict(PyObject *map, Py_ssize_t nmap, PyObject *dict, PyObject **values,
            int deref)
{
    Py_ssize_t j;
    assert(PyTuple_Check(map));
    assert(PyDict_Check(dict));
    assert(PyTuple_Size(map) >= nmap);
    for (j = nmap; --j >= 0; ) {
        PyObject *key = PyTuple_GET_ITEM(map, j);
        PyObject *value = values[j];
        assert(PyString_Check(key));
        if (deref) {
            assert(PyCell_Check(value));
            value = PyCell_GET(value);
        }
        if (value == NULL) {
            if (PyObject_DelItem(dict, key) != 0)
                PyErr_Clear();
        }
        else {
            if (PyObject_SetItem(dict, key, value) != 0)
                PyErr_Clear();
        }
    }
}
Exemplo n.º 2
0
static int _p_object_newindex_set(lua_State *L, py_object *obj, int keyn, int valuen) {
    PyObject *value;
    PyObject *key = LuaConvert(L, keyn);
    if (!key) luaL_argerror(L, 1, "failed to convert key");

    lua_Object lobj = lua_getparam(L, valuen);

    if (!lua_isnil(L, lobj)) {
        value = LuaConvert(L, valuen);
        if (!value) {
            Py_DECREF(key);
            luaL_argerror(L, 1, "failed to convert value");
        }
        // setitem (obj[0] = 1) if int else setattr(obj.val = 1)
        if (obj->asindx) {
            if (PyObject_SetItem(obj->o, key, value) == -1) {
                PyErr_Print();
                lua_error(L, "failed to set item");
            }
        } else if (PyObject_SetAttr(obj->o, key, value) == -1) {
            PyErr_Print();
            lua_error(L, "failed to set item");
        }
        Py_DECREF(value);
    } else {
        if (PyObject_DelItem(obj->o, key) == -1) {
            PyErr_Print();
            lua_error(L, "failed to delete item");
        }
    }
    Py_DECREF(key);
    return 0;
}
Exemplo n.º 3
0
static int _p_object_newindex_set(lua_State *L, py_object *pobj, int keyn, int valuen) {
    lua_Object lkey = lua_getparam(L, keyn);
    PyObject *key = lua_stack_convert(L, keyn, lkey);
    if (!key) luaL_argerror(L, 1, "failed to convert key");
    lua_Object lval = lua_getparam(L, valuen);
    if (!lua_isnil(L, lval)) {
        PyObject *value = lua_stack_convert(L, valuen, lval);
        if (!value) {
            if (!is_object_container(L, lkey)) Py_DECREF(key);
            luaL_argerror(L, 1, "failed to convert value");
        }
        // setitem (obj[0] = 1) if int else setattr(obj.val = 1)
        if (pobj->asindx) {
            if (PyObject_SetItem(pobj->object, key, value) == -1) {
                if (!is_object_container(L, lkey)) Py_DECREF(key);
                if (!is_object_container(L, lval)) Py_DECREF(value);
                lua_new_error(L, "failed to set item");
            }
        } else if (PyObject_SetAttr(pobj->object, key, value) == -1) {
            if (!is_object_container(L, lkey)) Py_DECREF(key);
            if (!is_object_container(L, lval)) Py_DECREF(value);
            lua_new_error(L, "failed to set attribute");
        }
        if (!is_object_container(L, lval))
            Py_DECREF(value);
    } else {
        if (PyObject_DelItem(pobj->object, key) == -1) {
            if (!is_object_container(L, lkey)) Py_DECREF(key);
            lua_new_error(L, "failed to delete item");
        }
    }
    if (!is_object_container(L, lkey))
        Py_DECREF(key);
    return 0;
}
Exemplo n.º 4
0
static int _p_object_newindex_set(lua_State *L, py_object *obj,
                  int keyn, int valuen)
{
    PyObject *value;
    PyObject *key = LuaConvert(L, keyn);

    if (!key) {
        return luaL_argerror(L, 1, "failed to convert key");
    }

    if (!lua_isnil(L, valuen)) {
        value = LuaConvert(L, valuen);
        if (!value) {
            Py_DECREF(key);
            return luaL_argerror(L, 1, "failed to convert value");
        }

        if (PyObject_SetItem(obj->o, key, value) == -1) {
            PyErr_Print();
            luaL_error(L, "failed to set item");
        }

        Py_DECREF(value);
    } else {
        if (PyObject_DelItem(obj->o, key) == -1) {
            PyErr_Print();
            luaL_error(L, "failed to delete item");
        }
    }

    Py_DECREF(key);
    return 0;
}
Exemplo n.º 5
0
static int
map_to_dict(PyObject *map, Py_ssize_t nmap, PyObject *dict, PyObject **values,
            int deref)
{
    Py_ssize_t j;
    assert(PyTuple_Check(map));
    assert(PyDict_Check(dict));
    assert(PyTuple_Size(map) >= nmap);
    for (j = nmap; --j >= 0; ) {
        PyObject *key = PyTuple_GET_ITEM(map, j);
        PyObject *value = values[j];
        assert(PyUnicode_Check(key));
        if (deref) {
            assert(PyCell_Check(value));
            value = PyCell_GET(value);
        }
        if (value == NULL) {
            if (PyObject_DelItem(dict, key) != 0) {
                if (PyErr_ExceptionMatches(PyExc_KeyError))
                    PyErr_Clear();
                else
                    return -1;
            }
        }
        else {
            if (PyObject_SetItem(dict, key, value) != 0)
                return -1;
        }
    }
    return 0;
}
Exemplo n.º 6
0
Arquivo: jiba5.c Projeto: jwilk/Pyrex
/* Implementation of jiba5 */

static PyObject *__pyx_f_5jiba5_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5jiba5_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_i;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;

  /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/jiba/jiba5.pyx":4 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_mylist); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
  if (PyObject_DelItem(__pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/jiba/jiba5.pyx":5 */
  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("jiba5.f");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}
static int
wrap_setitem(PyObject *self, PyObject *key, PyObject *value)
{
    if (value == NULL)
	return PyObject_DelItem(Proxy_GET_OBJECT(self), key);
    else
	return PyObject_SetItem(Proxy_GET_OBJECT(self), key, value);
}
Exemplo n.º 8
0
Arquivo: del.c Projeto: jwilk/Pyrex
/* Implementation of del */

static PyObject *__pyx_f_3del_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3del_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_b = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {"a","b",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_a, &__pyx_v_b)) return 0;
  Py_INCREF(__pyx_v_a);
  Py_INCREF(__pyx_v_b);

  /* "/Local/Projects/D/Pyrex/Source/Tests/3/del.pyx":3 */
  if (PyObject_DelAttr(__pyx_m, __pyx_n_g) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}

  /* "/Local/Projects/D/Pyrex/Source/Tests/3/del.pyx":4 */
  if (PyObject_DelItem(__pyx_v_a, __pyx_v_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}

  /* "/Local/Projects/D/Pyrex/Source/Tests/3/del.pyx":5 */
  __pyx_1 = PyObject_GetItem(__pyx_v_a, __pyx_v_b); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(42); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;}
  if (PyObject_DelItem(__pyx_1, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/Local/Projects/D/Pyrex/Source/Tests/3/del.pyx":6 */
  if (PyObject_DelAttr(__pyx_v_a, __pyx_n_spam) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}

  /* "/Local/Projects/D/Pyrex/Source/Tests/3/del.pyx":7 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_a, __pyx_n_spam); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}
  if (PyObject_DelAttr(__pyx_1, __pyx_n_eggs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("del.f");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_a);
  Py_DECREF(__pyx_v_b);
  return __pyx_r;
}
Exemplo n.º 9
0
static int Proxy_setitem(ProxyObject *self,
        PyObject *key, PyObject* value)
{
    Proxy__ENSURE_WRAPPED_OR_RETURN_MINUS1(self);

    if (value == NULL)
        return PyObject_DelItem(self->wrapped, key);
    else
        return PyObject_SetItem(self->wrapped, key, value);
}
Exemplo n.º 10
0
static int
proxy_setitem(PyWeakReference *proxy, PyObject *key, PyObject *value)
{
    if (!proxy_checkref(proxy))
        return -1;

    if (value == NULL)
        return PyObject_DelItem(PyWeakref_GET_OBJECT(proxy), key);
    else
        return PyObject_SetItem(PyWeakref_GET_OBJECT(proxy), key, value);
}
Exemplo n.º 11
0
/*
 * Remove the function module from sys.modules
 *
 * >>> del sys.modules[func.oidstr]
 *
 * -1 on error.
 */
int
PyPgFunction_RemoveModule(PyObj func)
{
	int rv;
	PyObj modules;

	modules = PyImport_GetModuleDict();

	rv = PySequence_Contains(modules, PyPgFunction_GetPyUnicodeOid(func));
	if (rv == 1)
		rv = PyObject_DelItem(modules, PyPgFunction_GetPyUnicodeOid(func));

	return(rv);
}
Exemplo n.º 12
0
JSBool
del_prop(JSContext* jscx, JSObject* jsobj, jsval key, jsval* rval)
{
    Context* pycx = NULL;
    PyObject* pykey = NULL;
    PyObject* pyval = NULL;
    JSBool ret = JS_FALSE;

    pycx = (Context*) JS_GetContextPrivate(jscx);
    if(pycx == NULL)
    {
        JS_ReportError(jscx, "Failed to get Python context.");
        goto done;
    }

    // Bail if there's no registered global handler.
    if(pycx->global == NULL)
    {
        ret = JS_TRUE;
        goto done;
    }
    
    // Check access to python land.
    if(Context_has_access(pycx, jscx, pycx->global, pykey) <= 0) goto done;

    // Bail if the global doesn't have a __delitem__
    if(!PyObject_HasAttrString(pycx->global, "__delitem__"))
    {
        ret = JS_TRUE;
        goto done;
    }

    pykey = js2py(pycx, key);
    if(pykey == NULL) goto done;

    if(PyObject_DelItem(pycx->global, pykey) < 0) goto done;

    ret = JS_TRUE;

done:
    Py_XDECREF(pykey);
    Py_XDECREF(pyval);
    return ret;
}
Exemplo n.º 13
0
static void MapPyValDelete(SMap *self, const char *key, s_erc *error)
{
	SMapPy *pMap = (SMapPy*)self;
	PyObject *pKey = NULL;


	S_CLR_ERR(error);
	S_CHECK_PY_MAP(pMap, "MapPyValDelete");

	pKey = s_set_pyobject_str(key, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "MapPyValDelete",
				  "Call to \"s_set_pyobject_str\" failed"))
		return;

	if (PyObject_DelItem(S_PY_DICT(pMap), pKey) == -1)
	{
		char *py_error = s_get_python_error_str();

		if (py_error)
		{
			S_CTX_ERR(error, S_FAILURE,
					  "MapPyValDelete",
					  "Call to \"PyObject_DelItem\" failed. Reported error: %s",
					  py_error);
			S_FREE(py_error);
		}
		else
		{
			S_CTX_ERR(error, S_FAILURE,
					  "MapPyValDelete",
					  "Call to \"PyObject_DelItem\" failed");
		}
	}

	/* decrement reference of pkey */
	Py_XDECREF(pKey);

	/* for S_CHECK_PY_MAP */
failure:
	return;
}
Exemplo n.º 14
0
static void
map_to_dict(PyObject *map, Py_ssize_t nmap, PyObject *dict, PyObject **values,
	    Py_ssize_t deref)
{
	Py_ssize_t j;
	for (j = nmap; --j >= 0; ) {
		PyObject *key = PyTuple_GET_ITEM(map, j);
		PyObject *value = values[j];
		if (deref)
			value = PyCell_GET(value);
		if (value == NULL) {
			if (PyObject_DelItem(dict, key) != 0)
				PyErr_Clear();
		}
		else {
			if (PyObject_SetItem(dict, key, value) != 0)
				PyErr_Clear();
		}
	}
}
Exemplo n.º 15
0
// TODO: Have mapping.hpp
NUITKA_MAY_BE_UNUSED static bool MAPPING_SYNC_FROM_VARIABLE( PyObject *mapping, PyObject *key, PyObject *value )
{
    if ( value )
    {
        int res = PyObject_SetItem(
            mapping,
            key,
            value
        );

        return res == 0;
    }
    else
    {
        PyObject *test_value = PyObject_GetItem(
            mapping,
            key
        );

        if ( test_value )
        {
            Py_DECREF( test_value );

            int res = PyObject_DelItem(
                mapping,
                key
            );

            return res == 0;
        }
        else
        {
            PyErr_Clear();
            return true;
        }
    }

}
Exemplo n.º 16
0
/**
 * Set a value for an entity attribute. If py_value == NULL then clear the attribute.
 * If the attribute exists and is a list, append this value to the list.
 *
 * NOTE: This function will Py_XDECREF(py_value).
 */
qd_error_t qd_entity_set_py(qd_entity_t* entity, const char* attribute, PyObject* py_value) {
    qd_error_clear();

    int result = 0;
    PyObject *py_key = PyString_FromString(attribute);
    if (py_key) {
        if (py_value == NULL) {     /* Delete the attribute */
            result = PyObject_DelItem((PyObject*)entity, py_key);
            PyErr_Clear();          /* Ignore error if it isn't there. */
        }
        else {
            PyObject *old = PyObject_GetItem((PyObject*)entity, py_key);
            PyErr_Clear();          /* Ignore error if it isn't there. */
            if (old && PyList_Check(old)) /* Add to list */
                result = PyList_Append(old, py_value);
            else                    /* Set attribute */
                result = PyObject_SetItem((PyObject*)entity, py_key, py_value);
            Py_XDECREF(old);
        }
    }
    Py_XDECREF(py_key);
    Py_XDECREF(py_value);
    return (py_key == NULL || result < 0) ? qd_error_py() : QD_ERROR_NONE;
}
Exemplo n.º 17
0
Arquivo: brown1.c Projeto: jwilk/Pyrex
static void __pyx_f_6brown1_f(void) {
  int __pyx_v_key;
  PyListObject *__pyx_v_l;
  PyObject *__pyx_v_d;
  PyObject *__pyx_1 = 0;
  __pyx_v_l = ((PyListObject *)Py_None); Py_INCREF(Py_None);
  __pyx_v_d = Py_None; Py_INCREF(Py_None);

  /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/brown/brown1.pyx":6 */
  if (PySequence_DelItem(((PyObject *)__pyx_v_l), __pyx_v_key) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}

  /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/brown/brown1.pyx":7 */
  __pyx_1 = PyInt_FromLong(__pyx_v_key); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}
  if (PyObject_DelItem(__pyx_v_d, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("brown1.f");
  __pyx_L0:;
  Py_DECREF(__pyx_v_l);
  Py_DECREF(__pyx_v_d);
}
Exemplo n.º 18
0
static SObject *MapPyValUnlink(SMap *self, const char *key, s_erc *error)
{
	const SMapPy *pMap = (const SMapPy *)self;
	PyObject *pKey;
	PyObject *pobject = NULL;
	SObject *tmp;


	S_CLR_ERR(error);
	S_CHECK_PY_MAP(pMap, "MapPyValUnlink");

	pKey = s_set_pyobject_str(key, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "MapPyValUnlink",
				  "Call to \"s_set_pyobject_str\" failed"))
		goto error;

	pobject = PyObject_GetItem(S_PY_DICT(pMap), pKey);
	if (pobject == NULL)
	{
		char *py_error = s_get_python_error_str();

		if (py_error)
		{
			S_CTX_ERR(error, S_FAILURE,
					  "MapPyValUnlink",
					  "Call to \"PyObject_GetItem\" failed. Reported error: %s",
					  py_error);
			S_FREE(py_error);
		}
		else
		{
			S_CTX_ERR(error, S_FAILURE,
					  "MapPyValUnlink",
					  "Call to \"PyObject_GetItem\" failed");
		}

		goto error;
	}

	if (PyObject_DelItem(S_PY_DICT(pMap), pKey) == -1)
	{
		char *py_error = s_get_python_error_str();

		if (py_error)
		{
			S_CTX_ERR(error, S_FAILURE,
					  "MapPyValUnlink",
					  "Call to \"PyObject_DelItem\" failed. Reported error: %s",
					  py_error);
			S_FREE(py_error);
		}
		else
		{
			S_CTX_ERR(error, S_FAILURE,
					  "MapPyValUnlink",
					  "Call to \"PyObject_DelItem\" failed");
		}

		goto error;
	}

	/* decrement reference of pKey */
	Py_XDECREF(pKey);

	/* convert to Speect object type */
	tmp = s_pyobject_2_sobject(pobject, error);

	/* decrement reference of pobject */
	Py_XDECREF(pobject);

	/* all ok */
	return tmp;


error:
	/* decrement reference of pKey */
	Py_XDECREF(pKey);

	/* decrement reference of pobject */
	Py_XDECREF(pobject);

	/* for S_CHECK_PY_MAP */
failure:
	return NULL;
}
Exemplo n.º 19
0
/*
 * PyPgFunction_load_module - create and load the module
 *
 * This execute the module body in a new module object iff the module does not
 * already exist in sys.modules.
 *
 * The PL protocol checks are not done here because this could be called from
 * the code of another function. It's the caller's responsibility to ensure that
 * the appropriate checks are being made at the appropriate time.
 */
PyObj
PyPgFunction_load_module(PyObj func)
{
	PyObj modules, module, modname, d, code, evalr;
	int rv;

	Assert(func != NULL);
	Assert(PyPgFunction_Check(func));

	modules = PyImport_GetModuleDict();

	rv = PySequence_Contains(modules, PyPgFunction_GetPyUnicodeOid(func));
	if (rv == -1)
		return(NULL);
	else if (rv == 1)
	{
		/*
		 * If this returns NULL, it's probably some weird race condition...
		 * The check above said it exists, so let's trust it.
		 */
		return(PyObject_GetItem(modules, PyPgFunction_GetPyUnicodeOid(func)));
	}

	/*
	 * Hasn't been loaded into sys.modules yet.
	 */

	code = PyPgFunction_get_code(func);
	if (code == NULL)
		return(NULL);

	modname = PyPgFunction_GetPyUnicodeOid(func);
	Py_INCREF(modname);
	PyObject_StrBytes(&modname);
	if (modname == NULL)
	{
		Py_DECREF(code);
		return(NULL);
	}

	module = PyModule_New(PyBytes_AS_STRING(modname));
	Py_DECREF(modname);
	if (module == NULL)
	{
		Py_DECREF(code);
		return(NULL);
	}

	d = PyModule_GetDict(module);
	if (PyDict_SetItemString(d, "__builtins__", Py_builtins_module) != 0)
		goto fail;
	/*
	 * __loader__ PEP302 support.
	 * This is what linecache uses to access the function's source
	 */
	if (PyDict_SetItemString(d, "__loader__", func) != 0)
		goto fail;
	if (PyDict_SetItemString(d, "__func__", func) != 0)
		goto fail;
	if (PyDict_SetItemString(d, "__file__", PyPgFunction_GetFilename(func)) != 0)
		goto fail;

	/*
	 * Module has to exist in sys.modules before code evaluates.
	 */
	if (PyObject_SetItem(modules, PyPgFunction_GetPyUnicodeOid(func), module) != 0)
		goto fail;

	/*
	 * Module context, therefore locals and globals are the same object.
	 */
	evalr = PyEval_EvalCode((PyCodeObject *) code, d, d);
	if (evalr == NULL)
	{
		/*
		 * Code evaluation failed. Remove the junk module from sys.modules.
		 */
		PyObject_DelItem(modules, PyPgFunction_GetPyUnicodeOid(func));
		goto fail;
	}
	Py_DECREF(evalr);
	Py_DECREF(code);

	return(module);
fail:
	Py_DECREF(code);
	Py_DECREF(module);
	return(NULL);
}
Exemplo n.º 20
0
BOOST_PYTHON_DECL void delitem(object const& target, object const& key)
{
    if (PyObject_DelItem(target.ptr(), key.ptr()) == -1)
        throw_error_already_set();
}
Exemplo n.º 21
0
 /* Do not delete this ...
 void SetItem(const CObject& key, const CObject& value)
 {
     if(PyObject_SetItem (Get(), key.Get(), value.Get()) == -1) {
         throw CKeyError ("SetItem failed");
     }
 }
 */
 void DelItem (const CObject& key)
 {
     if(PyObject_DelItem (Get(), key.Get()) == -1) {
         throw CKeyError ("DelItem failed");
     }
 }