summaryrefslogtreecommitdiff
path: root/glib/pygsource.c
diff options
context:
space:
mode:
Diffstat (limited to 'glib/pygsource.c')
-rw-r--r--glib/pygsource.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/glib/pygsource.c b/glib/pygsource.c
index 298b928..d0176ab 100644
--- a/glib/pygsource.c
+++ b/glib/pygsource.c
@@ -82,7 +82,7 @@ source_repr(PyGSource *self, const char *type)
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 *
@@ -109,7 +109,7 @@ pyg_source_attach(PyGSource *self, PyObject *args, PyObject *kwargs)
}
id = g_source_attach(self->source, context);
- return _PyLong_FromLong(id);
+ return PYGLIB_PyLong_FromLong(id);
}
static PyObject *
@@ -182,7 +182,7 @@ pyg_source_get_context(PyGSource *self)
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;
@@ -255,12 +255,12 @@ pyg_source_get_current_time(PyGSource *self)
}
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 }
};
@@ -283,7 +283,7 @@ pyg_source_get_priority(PyGSource *self, void *closure)
{
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
@@ -296,12 +296,12 @@ pyg_source_set_priority(PyGSource *self, PyObject *value, void *closure)
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;
}
@@ -339,7 +339,7 @@ pyg_source_get_id(PyGSource *self, void *closure)
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[] = {
@@ -387,10 +387,12 @@ pyg_source_clear(PyGSource *self)
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);
@@ -426,7 +428,7 @@ pyg_source_prepare(GSource *source, gint *timeout)
}
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;
@@ -652,7 +654,7 @@ pyg_poll_fd_dealloc(PyGPollFD *self)
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);
}