[23080] trunk/dports/python/py-gobject
source_changes at macosforge.org
source_changes at macosforge.org
Sat Mar 24 10:34:37 PDT 2007
Revision: 23080
http://trac.macosforge.org/projects/macports/changeset/23080
Author: yves at macports.org
Date: 2007-03-24 10:34:37 -0700 (Sat, 24 Mar 2007)
Log Message:
-----------
Add patch for object-init segfault related to ticket:11118
Modified Paths:
--------------
trunk/dports/python/py-gobject/Portfile
Added Paths:
-----------
trunk/dports/python/py-gobject/files/
trunk/dports/python/py-gobject/files/pygobject-init-v3.diff
Modified: trunk/dports/python/py-gobject/Portfile
===================================================================
--- trunk/dports/python/py-gobject/Portfile 2007-03-24 17:22:35 UTC (rev 23079)
+++ trunk/dports/python/py-gobject/Portfile 2007-03-24 17:34:37 UTC (rev 23080)
@@ -3,6 +3,7 @@
PortSystem 1.0
name py-gobject
version 2.12.3
+revision 1
categories python gnome
maintainers yves at macports.org
description Python bindings for GObject.
@@ -19,4 +20,6 @@
use_bzip2 yes
checksums md5 009986021225b7ea6e0ba848707785af
-depends_lib port:glib2 port:python24
+patchfiles pygobject-init-v3.diff
+
+depends_lib port:glib2 port:libxslt port:python24
Added: trunk/dports/python/py-gobject/files/pygobject-init-v3.diff
===================================================================
--- trunk/dports/python/py-gobject/files/pygobject-init-v3.diff (rev 0)
+++ trunk/dports/python/py-gobject/files/pygobject-init-v3.diff 2007-03-24 17:34:37 UTC (rev 23080)
@@ -0,0 +1,155 @@
+Index: gobject/pygobject.h
+===================================================================
+--- gobject/pygobject.h (revision 639)
++++ gobject/pygobject.h (working copy)
+@@ -274,53 +274,107 @@
+ PyEval_RestoreThread(_save); \
+ } G_STMT_END
+
+-#define init_pygobject() G_STMT_START { \
+- PyObject *gobject = PyImport_ImportModule("gobject"); \
+- if (gobject != NULL) { \
+- PyObject *mdict = PyModule_GetDict(gobject); \
+- PyObject *cobject = PyDict_GetItemString(mdict, "_PyGObject_API"); \
+- if (PyCObject_Check(cobject)) \
+- _PyGObject_API = (struct _PyGObject_Functions *)PyCObject_AsVoidPtr(cobject); \
+- else { \
+- PyErr_SetString(PyExc_RuntimeError, \
+- "could not find _PyGObject_API object"); \
+- return; \
+- } \
+- } else { \
+- PyErr_SetString(PyExc_ImportError, \
+- "could not import gobject"); \
+- return; \
+- } \
++
++/**
++ * pygobject_init:
++ * @req_major: minimum version major number, or -1
++ * @req_minor: minimum version minor number, or -1
++ * @req_micro: minimum version micro number, or -1
++ *
++ * Imports and initializes the 'gobject' python module. Can
++ * optionally check for a required minimum version if @req_major,
++ * @req_minor, and @req_micro are all different from -1.
++ *
++ * Returns: a new reference to the gobject module on success, NULL in
++ * case of failure (and raises ImportError).
++ **/
++static inline PyObject *
++pygobject_init(int req_major, int req_minor, int req_micro)
++{
++ PyObject *gobject, *cobject;
++
++ gobject = PyImport_ImportModule("gobject");
++ if (!gobject) {
++ if (PyErr_Occurred())
++ {
++ PyObject *type, *value, *traceback;
++ PyObject *py_orig_exc;
++ PyErr_Fetch(&type, &value, &traceback);
++ py_orig_exc = PyObject_Repr(value);
++ Py_XDECREF(type);
++ Py_XDECREF(value);
++ Py_XDECREF(traceback);
++ PyErr_Format(PyExc_ImportError,
++ "could not import gobject (error was: %s)",
++ PyString_AsString(py_orig_exc));
++ Py_DECREF(py_orig_exc);
++ } else {
++ PyErr_SetString(PyExc_ImportError,
++ "could not import gobject (no error given)");
++ }
++ return NULL;
++ }
++
++ cobject = PyObject_GetAttrString(gobject, "_PyGObject_API");
++ if (cobject && PyCObject_Check(cobject))
++ _PyGObject_API = (struct _PyGObject_Functions *) PyCObject_AsVoidPtr(cobject);
++ else {
++ PyErr_SetString(PyExc_ImportError,
++ "could not import gobject (could not find _PyGObject_API object)");
++ Py_DECREF(gobject);
++ return NULL;
++ }
++
++ if (req_major != -1)
++ {
++ int found_major, found_minor, found_micro;
++ PyObject *version;
++
++ version = PyObject_GetAttrString(gobject, "pygobject_version");
++ if (!version)
++ version = PyObject_GetAttrString(gobject, "pygtk_version");
++ if (!version) {
++ PyErr_SetString(PyExc_ImportError,
++ "could not import gobject (version too old)");
++ Py_DECREF(gobject);
++ return NULL;
++ }
++ if (!PyArg_ParseTuple(version, "iii",
++ &found_major, &found_minor, &found_micro)) {
++ PyErr_SetString(PyExc_ImportError,
++ "could not import gobject (version has invalid format)");
++ Py_DECREF(version);
++ Py_DECREF(gobject);
++ return NULL;
++ }
++ Py_DECREF(version);
++ if (req_major != found_major ||
++ req_minor > found_minor ||
++ (req_minor == found_minor && req_micro > found_micro)) {
++ PyErr_Format(PyExc_ImportError,
++ "could not import gobject (version mismatch, %d.%d.%d is required, "
++ "found %d.%d.%d)", req_major, req_minor, req_micro,
++ found_major, found_minor, found_micro);
++ Py_DECREF(gobject);
++ return NULL;
++ }
++ }
++ return gobject;
++}
++
++/* deprecated macro, use pygobject_init() instead. */
++#define init_pygobject() G_STMT_START { \
++ if (!pygobject_init(-1, -1, -1)) \
++ return; \
+ } G_STMT_END
+
+-#define init_pygobject_check(req_major, req_minor, req_micro) G_STMT_START { \
+- PyObject *gobject, *mdict, *version; \
+- int found_major, found_minor, found_micro; \
+- init_pygobject(); \
+- gobject = PyImport_ImportModule("gobject"); \
+- mdict = PyModule_GetDict(gobject); \
+- version = PyDict_GetItemString(mdict, "pygobject_version"); \
+- if (!version) \
+- version = PyDict_GetItemString(mdict, "pygtk_version"); \
+- if (!version) { \
+- PyErr_SetString(PyExc_ImportError, \
+- "PyGObject version too old"); \
+- return; \
+- } \
+- if (!PyArg_ParseTuple(version, "iii", \
+- &found_major, &found_minor, &found_micro)) \
+- return; \
+- if (req_major != found_major || \
+- req_minor > found_minor || \
+- (req_minor == found_minor && req_micro > found_micro)) { \
+- PyErr_Format(PyExc_ImportError, \
+- "PyGObject version mismatch, %d.%d.%d is required, " \
+- "found %d.%d.%d.", req_major, req_minor, req_micro, \
+- found_major, found_minor, found_micro); \
+- return; \
+- } \
++/* deprecated macro, use pygobject_init() instead. */
++#define init_pygobject_check(req_major, req_minor, req_micro) G_STMT_START { \
++ if (!pygobject_init(req_major, req_minor, req_micro)) \
++ return; \
+ } G_STMT_END
+
++
+ #endif /* !_INSIDE_PYGOBJECT_ */
+
+ G_END_DECLS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070324/92b2cb2a/attachment.html
More information about the macports-changes
mailing list