Example #1
0
File: del.c Project: 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;
}
Example #2
0
BOOST_PYTHON_DECL void delattr(object const& target, object const& key)
{
    if (PyObject_DelAttr(target.ptr(), key.ptr()) == -1)
        throw_error_already_set();
}