MCPcopy Create free account
hub / github.com/SamuraiT/mecab-python3 / SwigPyObject_dealloc

Function SwigPyObject_dealloc

src/MeCab/MeCab_wrap.cpp:1526–1575  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1524SwigPyObject_New(void *ptr, swig_type_info *ty, int own);
1525
1526SWIGRUNTIME void
1527SwigPyObject_dealloc(PyObject *v)
1528{
1529 SwigPyObject *sobj = (SwigPyObject *) v;
1530 PyObject *next = sobj->next;
1531 if (sobj->own == SWIG_POINTER_OWN) {
1532 swig_type_info *ty = sobj->ty;
1533 SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
1534 PyObject *destroy = data ? data->destroy : 0;
1535 if (destroy) {
1536 /* destroy is always a VARARGS method */
1537 PyObject *res;
1538
1539 /* PyObject_CallFunction() has the potential to silently drop
1540 the active exception. In cases of unnamed temporary
1541 variable or where we just finished iterating over a generator
1542 StopIteration will be active right now, and this needs to
1543 remain true upon return from SwigPyObject_dealloc. So save
1544 and restore. */
1545
1546 PyObject *type = NULL, *value = NULL, *traceback = NULL;
1547 PyErr_Fetch(&type, &value, &traceback);
1548
1549 if (data->delargs) {
1550 /* we need to create a temporary object to carry the destroy operation */
1551 PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0);
1552 res = SWIG_Python_CallFunctor(destroy, tmp);
1553 Py_DECREF(tmp);
1554 } else {
1555 PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
1556 PyObject *mself = PyCFunction_GET_SELF(destroy);
1557 res = ((*meth)(mself, v));
1558 }
1559 if (!res)
1560 PyErr_WriteUnraisable(destroy);
1561
1562 PyErr_Restore(type, value, traceback);
1563
1564 Py_XDECREF(res);
1565 }
1566#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
1567 else {
1568 const char *name = SWIG_TypePrettyName(ty);
1569 printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
1570 }
1571#endif
1572 }
1573 Py_XDECREF(next);
1574 PyObject_DEL(v);
1575}
1576
1577SWIGRUNTIME PyObject*
1578SwigPyObject_append(PyObject* v, PyObject* next)

Callers

nothing calls this directly

Calls 2

SwigPyObject_NewFunction · 0.85
SWIG_TypePrettyNameFunction · 0.85

Tested by

no test coverage detected