diff options
author | Johan Dahlin <johan@gnome.org> | 2008-07-26 14:04:48 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2008-07-26 14:04:48 +0000 |
commit | 130e20efbdc32e7b49960f24fac59c04fb613f87 (patch) | |
tree | cc42b8c6c917ae1924756d43f37d567a7752bf1f | |
parent | 73bb2db55342c2b5e22ad87e14903c92352932b4 (diff) | |
download | pygobject-130e20efbdc32e7b49960f24fac59c04fb613f87.tar.gz pygobject-130e20efbdc32e7b49960f24fac59c04fb613f87.tar.xz pygobject-130e20efbdc32e7b49960f24fac59c04fb613f87.zip |
Also export PyInit_glib import glib._glib instead of just _glib
2008-07-26 Johan Dahlin <johan@gnome.org>
* glib/Makefile.am:
Also export PyInit_glib
* glib/__init__.py:
import glib._glib instead of just _glib
* glib/pyglib-python-compat.h:
* glib/pygoptioncontext.c (pyg_option_context_parse):
* glib/pygsource.c (source_repr), (pyg_source_attach),
(pyg_source_get_priority), (pyg_source_set_priority),
(pyg_source_get_id), (pyg_source_prepare), (pyg_poll_fd_repr):
* glib/pygspawn.c (pyg_pid_close), (pyg_pid_free), (pyg_pid_new),
(pyglib_spawn_async), (pyglib_spawn_register_types):
Go over the rest and replace missing symbols on python3.
the glib module successfully compiles and runs now.
svn path=/trunk/; revision=874
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | glib/Makefile.am | 2 | ||||
-rw-r--r-- | glib/__init__.py | 2 | ||||
-rw-r--r-- | glib/pyglib-python-compat.h | 7 | ||||
-rw-r--r-- | glib/pygoptioncontext.c | 4 | ||||
-rw-r--r-- | glib/pygsource.c | 26 | ||||
-rw-r--r-- | glib/pygspawn.c | 36 |
7 files changed, 60 insertions, 33 deletions
@@ -1,5 +1,21 @@ 2008-07-26 Johan Dahlin <johan@gnome.org> + * glib/Makefile.am: + Also export PyInit_glib + * glib/__init__.py: + import glib._glib instead of just _glib + * glib/pyglib-python-compat.h: + * glib/pygoptioncontext.c (pyg_option_context_parse): + * glib/pygsource.c (source_repr), (pyg_source_attach), + (pyg_source_get_priority), (pyg_source_set_priority), + (pyg_source_get_id), (pyg_source_prepare), (pyg_poll_fd_repr): + * glib/pygspawn.c (pyg_pid_close), (pyg_pid_free), (pyg_pid_new), + (pyglib_spawn_async), (pyglib_spawn_register_types): + Go over the rest and replace missing symbols on python3. + the glib module successfully compiles and runs now. + +2008-07-26 Johan Dahlin <johan@gnome.org> + * glib/pygiochannel.c (py_io_channel_shutdown), (py_io_channel_set_buffer_size), (py_io_channel_get_buffer_size), (py_io_channel_set_buffered), (py_io_channel_get_buffered), diff --git a/glib/Makefile.am b/glib/Makefile.am index 8a8c5f3..2877b5f 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -28,7 +28,7 @@ libpyglib_2_0_la_SOURCES = \ pyglib-python-compat.h _glib_la_CFLAGS = $(GLIB_CFLAGS) -_glib_la_LDFLAGS = $(common_ldflags) -export-symbols-regex init_glib +_glib_la_LDFLAGS = $(common_ldflags) -export-symbols-regex "_glib|PyInit__glib" _glib_la_LIBADD = $(GLIB_LIBS) libpyglib-2.0.la _glib_la_SOURCES = \ glibmodule.c \ diff --git a/glib/__init__.py b/glib/__init__.py index 9730ea7..28a1242 100644 --- a/glib/__init__.py +++ b/glib/__init__.py @@ -27,7 +27,7 @@ try: except ImportError: pass -from _glib import * +from glib._glib import * _PyGLib_API = _glib._PyGLib_API del _glib diff --git a/glib/pyglib-python-compat.h b/glib/pyglib-python-compat.h index ccf2b85..b7a1970 100644 --- a/glib/pyglib-python-compat.h +++ b/glib/pyglib-python-compat.h @@ -55,12 +55,16 @@ PyTypeObject symbol = { \ #define _PyUnicode_AsStringAndSize PyString_AsStringAndSize #define _PyUnicode_FromString PyString_FromString #define _PyUnicode_FromStringAndSize PyString_FromStringAndSize +#define _PyUnicode_FromFormat PyString_FromFormat #define _PyUnicode_AS_STRING PyString_AS_STRING #define _PyUnicode_GET_SIZE PyString_GET_SIZE #define _PyUnicode_Resize _PyString_Resize #define _PyLong_Check PyInt_Check #define _PyLong_FromLong PyInt_FromLong #define _PyLong_AsLong PyInt_AsLong +#define RO READONLY +#define _PyLongObject PyIntObject +#define _PyLong_Type PyInt_Type #else #define PYGLIB_MODULE_START(symbol, modname) \ static struct PyModuleDef _##symbol##module = { \ @@ -99,12 +103,15 @@ PyTypeObject symbol = { \ #define _PyUnicode_AsStringAndSize(obj, buf, size) PyUnicode_AsStringAndSize(obj, size) #define _PyUnicode_FromString PyUnicode_FromString #define _PyUnicode_FromStringAndSize PyUnicode_FromStringAndSize +#define _PyUnicode_FromFormat PyUnicode_FromFormat #define _PyUnicode_AS_STRING _PyUnicode_AsString #define _PyUnicode_GET_SIZE PyUnicode_GET_SIZE #define _PyUnicode_Resize PyUnicode_Resize #define _PyLong_Check PyLong_Check #define _PyLong_FromLong PyLong_FromLong #define _PyLong_AsLong PyLong_AsLong +#define _PyLongObject PyLongObject +#define _PyLong_Type PyLong_Type #endif #endif /* __PYGLIB_PYTHON_COMPAT_H__ */ diff --git a/glib/pygoptioncontext.c b/glib/pygoptioncontext.c index 50a52fa..a180565 100644 --- a/glib/pygoptioncontext.c +++ b/glib/pygoptioncontext.c @@ -97,7 +97,7 @@ pyg_option_context_parse(PyGOptionContext *self, for (pos = 0; pos < argv_length; pos++) { arg = PyList_GetItem(argv, pos); - argv_content[pos] = g_strdup(PyString_AsString(arg)); + argv_content[pos] = g_strdup(_PyUnicode_AsString(arg)); if (argv_content[pos] == NULL) { g_strfreev(argv_content); @@ -125,7 +125,7 @@ pyg_option_context_parse(PyGOptionContext *self, new_argv = PyList_New(g_strv_length(argv_content)); for (pos = 0; pos < argv_length; pos++) { - arg = PyString_FromString(argv_content[pos]); + arg = _PyUnicode_FromString(argv_content[pos]); PyList_SetItem(new_argv, pos, arg); } diff --git a/glib/pygsource.c b/glib/pygsource.c index 6bdddee..aad98db 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 PyString_FromString(buf); + return _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 PyInt_FromLong(id); + return _PyLong_FromLong(id); } static PyObject * @@ -283,7 +283,7 @@ pyg_source_get_priority(PyGSource *self, void *closure) { CHECK_DESTROYED(self, NULL); - return PyInt_FromLong(g_source_get_priority(self->source)); + return _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 (!PyInt_Check(value)) { + if (!_PyLong_Check(value)) { PyErr_SetString(PyExc_TypeError, "type mismatch"); return -1; } - g_source_set_priority(self->source, PyInt_AsLong(value)); + g_source_set_priority(self->source, _PyLong_AsLong(value)); return 0; } @@ -339,7 +339,7 @@ pyg_source_get_id(PyGSource *self, void *closure) return NULL; } - return PyInt_FromLong(g_source_get_id(self->source)); + return _PyLong_FromLong(g_source_get_id(self->source)); } static PyGetSetDef pyg_source_getsets[] = { @@ -426,7 +426,7 @@ pyg_source_prepare(GSource *source, gint *timeout) } ret = PyObject_IsTrue(PyTuple_GET_ITEM(t, 0)); - *timeout = PyInt_AsLong(PyTuple_GET_ITEM(t, 1)); + *timeout = _PyLong_AsLong(PyTuple_GET_ITEM(t, 1)); if (*timeout == -1 && PyErr_Occurred()) { ret = FALSE; @@ -636,9 +636,9 @@ pyg_timeout_init(PyGSource *self, PyObject *args, PyObject *kwargs) PYGLIB_DEFINE_TYPE("glib.PollFD", PyGPollFD_Type, PyGPollFD) static PyMemberDef pyg_poll_fd_members[] = { - { "fd", T_INT, offsetof(PyGPollFD, pollfd.fd), RO }, - { "events", T_USHORT, offsetof(PyGPollFD, pollfd.events), RO }, - { "revents", T_USHORT, offsetof(PyGPollFD, pollfd.revents), RO }, + { "fd", T_INT, offsetof(PyGPollFD, pollfd.fd), READONLY }, + { "events", T_USHORT, offsetof(PyGPollFD, pollfd.events), READONLY }, + { "revents", T_USHORT, offsetof(PyGPollFD, pollfd.revents), READONLY }, { NULL, 0, 0, 0 } }; @@ -652,9 +652,9 @@ pyg_poll_fd_dealloc(PyGPollFD *self) static PyObject * pyg_poll_fd_repr(PyGPollFD *self) { - return PyString_FromFormat("<GPollFD %d (%d) at 0x%lx>", - self->pollfd.fd, self->pollfd.events, - (long)self); + return _PyUnicode_FromFormat("<GPollFD %d (%d) at 0x%lx>", + self->pollfd.fd, self->pollfd.events, + (long)self); } static int diff --git a/glib/pygspawn.c b/glib/pygspawn.c index 7bb76b5..69a120b 100644 --- a/glib/pygspawn.c +++ b/glib/pygspawn.c @@ -32,12 +32,12 @@ struct _PyGChildSetupData { PyObject *data; }; -PYGLIB_DEFINE_TYPE("glib.Pid", PyGPid_Type, PyIntObject) +PYGLIB_DEFINE_TYPE("glib.Pid", PyGPid_Type, _PyLongObject) static PyObject * -pyg_pid_close(PyIntObject *self, PyObject *args, PyObject *kwargs) +pyg_pid_close(PyObject *self, PyObject *args, PyObject *kwargs) { - g_spawn_close_pid((GPid) self->ob_ival); + g_spawn_close_pid(_PyLong_AsLong(self)); Py_INCREF(Py_None); return Py_None; } @@ -48,10 +48,10 @@ static PyMethodDef pyg_pid_methods[] = { }; static void -pyg_pid_free(PyIntObject *gpid) +pyg_pid_free(PyObject *gpid) { - g_spawn_close_pid((GPid) gpid->ob_ival); - PyInt_Type.tp_free((void *) gpid); + g_spawn_close_pid((GPid) _PyLong_AsLong(gpid)); + _PyLong_Type.tp_free((void *) gpid); } static int @@ -64,10 +64,14 @@ pyg_pid_tp_init(PyObject *self, PyObject *args, PyObject *kwargs) PyObject * pyg_pid_new(GPid pid) { - PyIntObject *pygpid; - pygpid = PyObject_NEW(PyIntObject, &PyGPid_Type); + _PyLongObject *pygpid; + pygpid = PyObject_NEW(_PyLongObject, &PyGPid_Type); +#if PY_VERSION_HEX >= 0x03000000 +# warning "FIXME: figure out how to subclass long" +#else pygpid->ob_ival = pid; +#endif return (PyObject *) pygpid; } @@ -145,7 +149,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) argv = g_new0(char *, len + 1); for (i = 0; i < len; ++i) { PyObject *tmp = PySequence_ITEM(pyargv, i); - if (!PyString_Check(tmp)) { + if (!_PyUnicode_Check(tmp)) { PyErr_SetString(PyExc_TypeError, "glib.spawn_async: " "first argument must be a sequence of strings"); @@ -153,7 +157,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) Py_XDECREF(tmp); return NULL; } - argv[i] = PyString_AsString(tmp); + argv[i] = _PyUnicode_AsString(tmp); Py_DECREF(tmp); } @@ -170,7 +174,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) envp = g_new0(char *, len + 1); for (i = 0; i < len; ++i) { PyObject *tmp = PySequence_ITEM(pyenvp, i); - if (!PyString_Check(tmp)) { + if (!_PyUnicode_Check(tmp)) { PyErr_SetString(PyExc_TypeError, "glib.spawn_async: " "second argument must be a sequence of strings"); @@ -179,7 +183,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) g_free(argv); return NULL; } - envp[i] = PyString_AsString(tmp); + envp[i] = _PyUnicode_AsString(tmp); Py_DECREF(tmp); } } @@ -224,21 +228,21 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) if (envp) g_free(envp); if (standard_input) - pystdin = PyInt_FromLong(*standard_input); + pystdin = _PyLong_FromLong(*standard_input); else { Py_INCREF(Py_None); pystdin = Py_None; } if (standard_output) - pystdout = PyInt_FromLong(*standard_output); + pystdout = _PyLong_FromLong(*standard_output); else { Py_INCREF(Py_None); pystdout = Py_None; } if (standard_error) - pystderr = PyInt_FromLong(*standard_error); + pystderr = _PyLong_FromLong(*standard_error); else { Py_INCREF(Py_None); pystderr = Py_None; @@ -250,7 +254,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) void pyglib_spawn_register_types(PyObject *d) { - PyGPid_Type.tp_base = &PyInt_Type; + PyGPid_Type.tp_base = &_PyLong_Type; PyGPid_Type.tp_flags = Py_TPFLAGS_DEFAULT; PyGPid_Type.tp_methods = pyg_pid_methods; PyGPid_Type.tp_init = pyg_pid_tp_init; |