diff options
| author | Felix Geyer <fgeyer@debian.org> | 2014-04-05 22:17:15 +0200 |
|---|---|---|
| committer | Felix Geyer <fgeyer@debian.org> | 2014-04-05 22:17:15 +0200 |
| commit | 1700c7d32f7d9d101cbba9f1fcb8bb57ed16a727 (patch) | |
| tree | 727251ad65172262944f82bb0f28601c3fb6f6b3 /src/libs/xpcom18a4/python | |
| parent | 1e85aed889b772c2f2daa7a6d9e8bd967aa213d8 (diff) | |
| download | virtualbox-upstream.tar.gz | |
Imported Upstream version 4.3.10-dfsgupstream/4.3.10-dfsgupstream
Diffstat (limited to 'src/libs/xpcom18a4/python')
| -rw-r--r-- | src/libs/xpcom18a4/python/server/loader.py | 14 | ||||
| -rw-r--r-- | src/libs/xpcom18a4/python/src/PyGBase.cpp | 3 | ||||
| -rw-r--r-- | src/libs/xpcom18a4/python/src/PyIID.cpp | 2 | ||||
| -rw-r--r-- | src/libs/xpcom18a4/python/src/PyISupports.cpp | 4 |
4 files changed, 14 insertions, 9 deletions
diff --git a/src/libs/xpcom18a4/python/server/loader.py b/src/libs/xpcom18a4/python/server/loader.py index b58755461..e59155a51 100644 --- a/src/libs/xpcom18a4/python/server/loader.py +++ b/src/libs/xpcom18a4/python/server/loader.py @@ -57,11 +57,15 @@ def FindCOMComponents(py_module): # For now, just run over all classes looking for likely candidates. comps = [] for name, object in py_module.__dict__.items(): - if type(object)==types.ClassType and \ - _has_good_attr(object, "_com_interfaces_") and \ - _has_good_attr(object, "_reg_clsid_") and \ - _has_good_attr(object, "_reg_contractid_"): - comps.append(object) + try: + if (type(object) == types.ClassType or issubclass(object, object)) and \ + _has_good_attr(object, "_com_interfaces_") and \ + _has_good_attr(object, "_reg_clsid_") and \ + _has_good_attr(object, "_reg_contractid_"): + comps.append(object) + except TypeError: + # The issubclass call raises TypeError when the obj is not a class. + pass; return comps def register_self(klass, compMgr, location, registryLocation, componentType): diff --git a/src/libs/xpcom18a4/python/src/PyGBase.cpp b/src/libs/xpcom18a4/python/src/PyGBase.cpp index 93fe03f90..0a935017a 100644 --- a/src/libs/xpcom18a4/python/src/PyGBase.cpp +++ b/src/libs/xpcom18a4/python/src/PyGBase.cpp @@ -195,7 +195,8 @@ void *PyG_Base::ThisAsIID( const nsIID &iid ) PyG_Base::AutoWrapPythonInstance(PyObject *ob, const nsIID &iid, nsISupports **ppret) { NS_PRECONDITION(ppret!=NULL, "null pointer when wrapping a Python instance!"); - NS_PRECONDITION(ob && PyInstance_Check(ob), "AutoWrapPythonInstance is expecting an non-NULL instance!"); + NS_PRECONDITION(ob && PyObject_HasAttrString(ob, "__class__"), + "AutoWrapPythonInstance is expecting an non-NULL instance!"); PRBool ok = PR_FALSE; // XXX - todo - this static object leaks! (but Python on Windows leaks 2000+ objects as it is ;-) static PyObject *func = NULL; // fetch this once and remember! diff --git a/src/libs/xpcom18a4/python/src/PyIID.cpp b/src/libs/xpcom18a4/python/src/PyIID.cpp index 2cdcf5c00..783c9c61a 100644 --- a/src/libs/xpcom18a4/python/src/PyIID.cpp +++ b/src/libs/xpcom18a4/python/src/PyIID.cpp @@ -114,7 +114,7 @@ Py_nsIID::IIDFromPyObject(PyObject *ob, nsIID *pRet) { } } else if (ob->ob_type == &type) { iid = ((Py_nsIID *)ob)->m_iid; - } else if (PyInstance_Check(ob)) { + } else if (PyObject_HasAttrString(ob, "__class__")) { // Get the _iidobj_ attribute PyObject *use_ob = PyObject_GetAttrString(ob, "_iidobj_"); if (use_ob==NULL) { diff --git a/src/libs/xpcom18a4/python/src/PyISupports.cpp b/src/libs/xpcom18a4/python/src/PyISupports.cpp index 508eeeae0..0802eeedd 100644 --- a/src/libs/xpcom18a4/python/src/PyISupports.cpp +++ b/src/libs/xpcom18a4/python/src/PyISupports.cpp @@ -321,7 +321,7 @@ Py_nsISupports::InterfaceFromPyObject(PyObject *ob, // support nsIVariant if (iid.Equals(NS_GET_IID(nsIVariant)) || iid.Equals(NS_GET_IID(nsIWritableVariant))) { // Check it is not already nsIVariant - if (PyInstance_Check(ob)) { + if (PyObject_HasAttrString(ob, "__class__")) { PyObject *sub_ob = PyObject_GetAttrString(ob, "_comobj_"); if (sub_ob==NULL) { PyErr_Clear(); @@ -344,7 +344,7 @@ Py_nsISupports::InterfaceFromPyObject(PyObject *ob, } // end of variant support. - if (PyInstance_Check(ob)) { + if (PyObject_HasAttrString(ob, "__class__")) { // Get the _comobj_ attribute PyObject *use_ob = PyObject_GetAttrString(ob, "_comobj_"); if (use_ob==NULL) { |
