static int xns_init(PyXPathNamespaceObject *self, PyElementObject *parentNode, PyObject *prefix, PyObject *namespaceURI) { if ((self == NULL || !PyXPathNamespace_Check(self)) || (parentNode == NULL || !PyElement_Check(parentNode)) || (prefix == NULL || !DOMString_NullCheck(prefix)) || (namespaceURI == NULL || !DOMString_Check(namespaceURI))) { PyErr_BadInternalCall(); return -1; } if (prefix == Py_None) { prefix = PyUnicode_FromUnicode(NULL, (Py_ssize_t)0); if (prefix == NULL) return -1; } else { Py_INCREF(prefix); } self->nodeName = prefix; Py_INCREF(namespaceURI); self->nodeValue = namespaceURI; Node_SET_PARENT(self, (PyNodeObject *) parentNode); return 0; }
static PyObject *node_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { static char *kwlist[] = { "parent", NULL }; NodeObject *parent=NULL; PyObject *self; if (type == &DomletteNode_Type) { PyErr_Format(PyExc_TypeError, "cannot create '%.100s' instances", type->tp_name); return NULL; } if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!:node", kwlist, &DomletteContainer_Type, &parent)) { return NULL; } self = type->tp_alloc(type, 0); if (self != NULL && parent != NULL) { Node_SET_PARENT(self, parent); Py_INCREF(parent); } return self; }