g_snprintf(buf, sizeof(buf), "<%s glib source at 0x%lx>",
desc, (long) self);
- return _PyUnicode_FromString(buf);
+ return PYGLIB_PyUnicode_FromString(buf);
}
static PyObject *
}
id = g_source_attach(self->source, context);
- return _PyLong_FromLong(id);
+ return PYGLIB_PyLong_FromLong(id);
}
static PyObject *
context = g_source_get_context(self->source);
if (context) {
- return pyglib_main_context_new(context);
+ return pyg_main_context_new(context);
} else {
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef pyg_source_methods[] = {
- { "attach", (PyCFunction)pyg_source_attach, METH_KEYWORDS },
+ { "attach", (PyCFunction)pyg_source_attach, METH_VARARGS|METH_KEYWORDS },
{ "destroy", (PyCFunction)pyg_source_destroy, METH_NOARGS },
{ "set_callback", (PyCFunction)pyg_source_set_callback, METH_VARARGS },
{ "get_context", (PyCFunction)pyg_source_get_context, METH_NOARGS },
{ "add_poll", (PyCFunction)pyg_source_add_poll, METH_KEYWORDS },
- { "remove_poll", (PyCFunction)pyg_source_remove_poll, METH_KEYWORDS },
+ { "remove_poll", (PyCFunction)pyg_source_remove_poll, METH_VARARGS|METH_KEYWORDS },
{ "get_current_time", (PyCFunction)pyg_source_get_current_time, METH_NOARGS },
{ NULL, NULL, 0 }
};
{
CHECK_DESTROYED(self, NULL);
- return _PyLong_FromLong(g_source_get_priority(self->source));
+ return PYGLIB_PyLong_FromLong(g_source_get_priority(self->source));
}
static int
return -1;
}
- if (!_PyLong_Check(value)) {
+ if (!PYGLIB_PyLong_Check(value)) {
PyErr_SetString(PyExc_TypeError, "type mismatch");
return -1;
}
- g_source_set_priority(self->source, _PyLong_AsLong(value));
+ g_source_set_priority(self->source, PYGLIB_PyLong_AsLong(value));
return 0;
}
return NULL;
}
- return _PyLong_FromLong(g_source_get_id(self->source));
+ return PYGLIB_PyLong_FromLong(g_source_get_id(self->source));
}
static PyGetSetDef pyg_source_getsets[] = {
static void
pyg_source_dealloc(PyGSource *self)
{
- PyObject_ClearWeakRefs((PyObject *)self);
-
+ /* Must be done first, so that there is no chance of Python's GC being
+ * called while tracking this half-deallocated object */
PyObject_GC_UnTrack((PyObject *)self);
+ PyObject_ClearWeakRefs((PyObject *)self);
+
pyg_source_clear(self);
PyObject_GC_Del(self);
}
ret = PyObject_IsTrue(PyTuple_GET_ITEM(t, 0));
- *timeout = _PyLong_AsLong(PyTuple_GET_ITEM(t, 1));
+ *timeout = PYGLIB_PyLong_AsLong(PyTuple_GET_ITEM(t, 1));
if (*timeout == -1 && PyErr_Occurred()) {
ret = FALSE;
static PyObject *
pyg_poll_fd_repr(PyGPollFD *self)
{
- return _PyUnicode_FromFormat("<GPollFD %d (%d) at 0x%lx>",
+ return PYGLIB_PyUnicode_FromFormat("<GPollFD %d (%d) at 0x%lx>",
self->pollfd.fd, self->pollfd.events,
(long)self);
}