[pygobject/py3k] Fix python 2.5 regressions
- From: John Ehresman <jpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/py3k] Fix python 2.5 regressions
- Date: Fri, 16 Apr 2010 19:26:00 +0000 (UTC)
commit 2e2fd145a4f09b67cd014d2eb9f9db5e1715f7ab
Author: John Ehresman <jpe wingware com>
Date: Fri Apr 16 15:22:35 2010 -0400
Fix python 2.5 regressions
glib/pyglib.c | 2 +-
gobject/propertyhelper.py | 8 +++++---
gobject/pygenum.c | 6 +++---
gobject/pygflags.c | 12 +++++++-----
gobject/pygobject.h | 2 +-
5 files changed, 17 insertions(+), 13 deletions(-)
---
diff --git a/glib/pyglib.c b/glib/pyglib.c
index 48e0fc1..d113bba 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)",
- _PyUnicode_AsString(py_orig_exc));
+ PYGLIB_PyUnicode_AsString(py_orig_exc));
Py_DECREF(py_orig_exc);
} else {
PyErr_SetString(PyExc_ImportError,
diff --git a/gobject/propertyhelper.py b/gobject/propertyhelper.py
index 68e3a27..3764e7a 100644
--- a/gobject/propertyhelper.py
+++ b/gobject/propertyhelper.py
@@ -102,7 +102,9 @@ class property(object):
self.setter = setter
if sys.version_info >= (3, 0):
- basestring = str
+ _basestring = str
+ else:
+ _basestring = basestring
if type is None:
type = object
@@ -110,11 +112,11 @@ class property(object):
self.default = self._get_default(default)
self._check_default()
- if not isinstance(nick, basestring):
+ if not isinstance(nick, _basestring):
raise TypeError("nick must be a string")
self.nick = nick
- if not isinstance(blurb, basestring):
+ if not isinstance(blurb, _basestring):
raise TypeError("blurb must be a string")
self.blurb = blurb
diff --git a/gobject/pygenum.c b/gobject/pygenum.c
index c47b953..a949a15 100644
--- a/gobject/pygenum.c
+++ b/gobject/pygenum.c
@@ -43,8 +43,8 @@ pyg_enum_val_new(PyObject* subclass, GType gtype, PyObject *intval)
item = PyObject_CallMethod((PyObject*)&PyLong_Type, "__new__", "OO",
subclass, intval);
#else
- item = ((PyTypeObject *)stub)->tp_alloc((PyTypeObject *)subclass, 0);
- ((PyLongObject*)item)->ob_ival = PyInt_AS_LONG(intval);
+ item = ((PyTypeObject *)subclass)->tp_alloc((PyTypeObject *)subclass, 0);
+ ((PyIntObject*)item)->ob_ival = PyInt_AS_LONG(intval);
#endif
((PyGEnum*)item)->gtype = gtype;
@@ -348,7 +348,7 @@ pygobject_enum_register_types(PyObject *d)
pygenum_class_key = g_quark_from_static_string("PyGEnum::class");
#if PY_VERSION_HEX < 0x03000000
- PyGEnum_Type.tp_base = PyInt_Type;
+ PyGEnum_Type.tp_base = &PyInt_Type;
PyGEnum_Type.tp_new = pyg_enum_new;
#else
PyGEnum_Type.tp_base = &PyLong_Type;
diff --git a/gobject/pygflags.c b/gobject/pygflags.c
index ab55337..09aee30 100644
--- a/gobject/pygflags.c
+++ b/gobject/pygflags.c
@@ -44,8 +44,8 @@ pyg_flags_val_new(PyObject* subclass, GType gtype, PyObject *intval)
item = PyObject_CallMethod((PyObject*)&PyLong_Type, "__new__", "OO",
subclass, intval);
#else
- item = ((PyTypeObject *)stub)->tp_alloc((PyTypeObject *)subclass, 0);
- ((PyLongObject*)item)->ob_ival = PyInt_AS_LONG(intval);
+ item = ((PyTypeObject *)subclass)->tp_alloc((PyTypeObject *)subclass, 0);
+ ((PyIntObject*)item)->ob_ival = PyInt_AsLong(intval);
#endif
((PyGFlags*)item)->gtype = gtype;
@@ -442,7 +442,9 @@ static PyNumberMethods pyg_flags_as_number = {
(binaryfunc)pyg_flags_warn, /* nb_multiply */
(binaryfunc)pyg_flags_warn, /* nb_divide */
(binaryfunc)pyg_flags_warn, /* nb_remainder */
-// (binaryfunc)pyg_flags_warn, /* nb_divmod */
+#if PY_VERSION_HEX < 0x03000000
+ (binaryfunc)pyg_flags_warn, /* nb_divmod */
+#endif
(ternaryfunc)pyg_flags_warn, /* nb_power */
0, /* nb_negative */
0, /* nb_positive */
@@ -462,8 +464,8 @@ pygobject_flags_register_types(PyObject *d)
pygflags_class_key = g_quark_from_static_string("PyGFlags::class");
#if PY_VERSION_HEX < 0x03000000
- PyGFlags_Type.tp_base = PyInt_Type;
- PyGFlags_Type.tp_new = pyg_enum_new;
+ PyGFlags_Type.tp_base = &PyInt_Type;
+ PyGFlags_Type.tp_new = pyg_flags_new;
#else
PyGFlags_Type.tp_base = &PyLong_Type;
PyGFlags_Type.tp_new = PyLong_Type.tp_new;
diff --git a/gobject/pygobject.h b/gobject/pygobject.h
index 8772aa4..4e97b24 100644
--- a/gobject/pygobject.h
+++ b/gobject/pygobject.h
@@ -320,7 +320,7 @@ pygobject_init(int req_major, int req_minor, int req_micro)
Py_XDECREF(traceback);
PyErr_Format(PyExc_ImportError,
"could not import gobject (error was: %s)",
- _PyUnicode_AsString(py_orig_exc));
+ PYGLIB_PyUnicode_AsString(py_orig_exc));
Py_DECREF(py_orig_exc);
} else {
PyErr_SetString(PyExc_ImportError,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]