diff options
Diffstat (limited to 'src/caja-python-object.c')
-rw-r--r-- | src/caja-python-object.c | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/caja-python-object.c b/src/caja-python-object.c index 7820d10..8d13c79 100644 --- a/src/caja-python-object.c +++ b/src/caja-python-object.c @@ -44,20 +44,6 @@ static GObjectClass *parent_class; -#if PY_MAJOR_VERSION >= 3 -#define STRING_CHECK(obj) PyUnicode_Check(obj) -#define STRING_FROMSTRING(str) PyUnicode_FromString(str) -#define STRING_ASSTRING(obj) PyUnicode_AsUTF8(obj) -#define INT_CHECK(obj) PyLong_Check(obj) -#define INT_ASLONG(obj) PyLong_AsLong(obj) -#else -#define STRING_CHECK(obj) PyString_Check(obj) -#define STRING_FROMSTRING(str) PyString_FromString(str) -#define STRING_ASSTRING(obj) PyString_AsString(obj) -#define INT_CHECK(obj) PyInt_Check(obj) -#define INT_ASLONG(obj) PyInt_AsLong(obj) -#endif - /* These macros assumes the following things: * a METHOD_NAME is defined with is a string * a goto label called beach @@ -99,7 +85,7 @@ static GObjectClass *parent_class; #define HANDLE_LIST(py_ret, type, type_name) \ { \ Py_ssize_t i = 0; \ - if (!PySequence_Check(py_ret) || STRING_CHECK(py_ret)) \ + if (!PySequence_Check(py_ret) || PyUnicode_Check(py_ret)) \ { \ PyErr_SetString(PyExc_TypeError, \ METHOD_NAME " must return a sequence"); \ @@ -208,7 +194,7 @@ caja_python_object_get_widget (CajaLocationWidgetProvider *provider, CHECK_OBJECT(object); CHECK_METHOD_NAME(object->instance); - py_uri = STRING_FROMSTRING(uri); + py_uri = PyUnicode_FromString(uri); py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME, "(NN)", py_uri, @@ -453,14 +439,14 @@ caja_python_object_update_file_info (CajaInfoProvider *provider, HANDLE_RETVAL(py_ret); - if (!INT_CHECK(py_ret)) + if (!PyLong_Check(py_ret)) { PyErr_SetString(PyExc_TypeError, METHOD_NAME " must return None or a int"); goto beach; } - ret = INT_ASLONG(py_ret); + ret = PyLong_AsLong(py_ret); if (!*handle && ret == CAJA_OPERATION_IN_PROGRESS) ret = CAJA_OPERATION_FAILED; @@ -553,7 +539,7 @@ caja_python_object_get_type (GTypeModule *module, NULL }; - debug_enter_args("type=%s", STRING_ASSTRING(PyObject_GetAttrString(type, "__name__"))); + debug_enter_args("type=%s", PyUnicode_AsUTF8(PyObject_GetAttrString(type, "__name__"))); info = g_new0 (GTypeInfo, 1); info->class_size = sizeof (CajaPythonObjectClass); @@ -565,7 +551,7 @@ caja_python_object_get_type (GTypeModule *module, Py_INCREF(type); type_name = g_strdup_printf("%s+CajaPython", - STRING_ASSTRING(PyObject_GetAttrString(type, "__name__"))); + PyUnicode_AsUTF8(PyObject_GetAttrString(type, "__name__"))); gtype = g_type_module_register_type (module, G_TYPE_OBJECT, |