diff options
author | Johan Dahlin <johan@gnome.org> | 2008-07-26 13:23:28 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2008-07-26 13:23:28 +0000 |
commit | e889e0030877bb0b3a7e83f945b8b07230973c01 (patch) | |
tree | d8dd4045f066a3e83dac29435102eeaeb4ad7986 /glib/pyglib.c | |
parent | 83627fd48cdd1a39eec874627ef97ed560e231b8 (diff) | |
download | pygobject-e889e0030877bb0b3a7e83f945b8b07230973c01.tar.gz pygobject-e889e0030877bb0b3a7e83f945b8b07230973c01.tar.xz pygobject-e889e0030877bb0b3a7e83f945b8b07230973c01.zip |
Add macros for supporting additional python versions. Start using them for
2008-07-26 Johan Dahlin <johan@gnome.org>
* glib/glibmodule.c (get_handler_priority), (pyglib_idle_add),
(pyglib_timeout_add), (pyglib_timeout_add_seconds),
(pyglib_io_add_watch), (pyglib_child_watch_add),
(pyglib_markup_escape_text), (pyglib_main_depth),
(pyglib_filename_from_utf8), (pyglib_get_application_name),
(pyglib_get_prgname), (PYGLIB_MODULE_START):
* glib/pygiochannel.c (py_io_channel_next),
(py_io_channel_shutdown), (py_io_channel_get_buffer_size),
(py_io_channel_get_buffered), (py_io_channel_get_encoding),
(py_io_channel_read_chars), (py_io_channel_write_chars),
(py_io_channel_write_lines), (py_io_channel_flush),
(py_io_channel_set_flags), (py_io_channel_get_flags),
(py_io_channel_get_buffer_condition), (py_io_channel_win32_poll),
(py_io_channel_read_line), (py_io_channel_read_lines),
(py_io_channel_seek), (pyglib_iochannel_register_types):
* glib/pyglib-private.h:
* glib/pyglib-python-compat.h:
* glib/pyglib.c (pyglib_init), (pyglib_error_check),
(pyglib_gerror_exception_check),
(pyglib_register_exception_for_domain):
Add macros for supporting additional python versions.
Start using them for the glib module. Tested on python 2.5 and 3.0.
svn path=/trunk/; revision=870
Diffstat (limited to 'glib/pyglib.c')
-rw-r--r-- | glib/pyglib.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/glib/pyglib.c b/glib/pyglib.c index ac9a45b..ac6ec42 100644 --- a/glib/pyglib.c +++ b/glib/pyglib.c @@ -61,7 +61,7 @@ pyglib_init(void) Py_XDECREF(traceback); PyErr_Format(PyExc_ImportError, "could not import glib (error was: %s)", - PyString_AsString(py_orig_exc)); + _PyUnicode_AsString(py_orig_exc)); Py_DECREF(py_orig_exc); } else PyErr_SetString(PyExc_ImportError, @@ -232,23 +232,23 @@ pyglib_error_check(GError **error) if (exception_table != NULL) { PyObject *item; - item = PyDict_GetItem(exception_table, PyInt_FromLong((*error)->domain)); + item = PyDict_GetItem(exception_table, _PyLong_FromLong((*error)->domain)); if (item != NULL) exc_type = item; } exc_instance = PyObject_CallFunction(exc_type, "z", (*error)->message); PyObject_SetAttrString(exc_instance, "domain", - d=PyString_FromString(g_quark_to_string((*error)->domain))); + d=_PyUnicode_FromString(g_quark_to_string((*error)->domain))); Py_DECREF(d); PyObject_SetAttrString(exc_instance, "code", - d=PyInt_FromLong((*error)->code)); + d=_PyLong_FromLong((*error)->code)); Py_DECREF(d); if ((*error)->message) { PyObject_SetAttrString(exc_instance, "message", - d=PyString_FromString((*error)->message)); + d=_PyUnicode_FromString((*error)->message)); Py_DECREF(d); } else { PyObject_SetAttrString(exc_instance, "message", Py_None); @@ -301,28 +301,28 @@ pyglib_gerror_exception_check(GError **error) Py_XDECREF(traceback); py_message = PyObject_GetAttrString(value, "message"); - if (!py_message || !PyString_Check(py_message)) { + if (!py_message || !_PyUnicode_Check(py_message)) { bad_gerror_message = "gobject.GError instances must have a 'message' string attribute"; goto bad_gerror; } py_domain = PyObject_GetAttrString(value, "domain"); - if (!py_domain || !PyString_Check(py_domain)) { + if (!py_domain || !_PyUnicode_Check(py_domain)) { bad_gerror_message = "gobject.GError instances must have a 'domain' string attribute"; Py_DECREF(py_message); goto bad_gerror; } py_code = PyObject_GetAttrString(value, "code"); - if (!py_code || !PyInt_Check(py_code)) { + if (!py_code || !_PyLong_Check(py_code)) { bad_gerror_message = "gobject.GError instances must have a 'code' int attribute"; Py_DECREF(py_message); Py_DECREF(py_domain); goto bad_gerror; } - g_set_error(error, g_quark_from_string(PyString_AsString(py_domain)), - PyInt_AsLong(py_code), PyString_AsString(py_message)); + g_set_error(error, g_quark_from_string(_PyUnicode_AsString(py_domain)), + _PyLong_AsLong(py_code), _PyUnicode_AsString(py_message)); Py_DECREF(py_message); Py_DECREF(py_code); @@ -360,7 +360,7 @@ pyglib_register_exception_for_domain(gchar *name, exception_table = PyDict_New(); PyDict_SetItem(exception_table, - PyInt_FromLong(error_domain), + _PyLong_FromLong(error_domain), exception); return exception; |