VirtualBox

Changeset 50710 in vbox


Ignore:
Timestamp:
Mar 6, 2014 1:08:28 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
92674
Message:

pyxpcom: Support new style python classes (derived from object), upstream changeset b6fce9508c70 (http://hg.mozilla.org/pyxpcom/rev/b6fce9508c70).

Location:
trunk/src/libs/xpcom18a4/python
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/python/server/loader.py

    r11746 r50710  
    5858    comps = []
    5959    for name, object in py_module.__dict__.items():
    60         if type(object)==types.ClassType and \
    61            _has_good_attr(object, "_com_interfaces_") and \
    62            _has_good_attr(object, "_reg_clsid_") and \
    63            _has_good_attr(object, "_reg_contractid_"):
    64             comps.append(object)
     60        try:
     61            if (type(object) == types.ClassType or issubclass(object, object)) and \
     62               _has_good_attr(object, "_com_interfaces_") and \
     63               _has_good_attr(object, "_reg_clsid_") and \
     64               _has_good_attr(object, "_reg_contractid_"):
     65                comps.append(object)
     66        except TypeError:
     67            # The issubclass call raises TypeError when the obj is not a class.
     68            pass;
    6569    return comps
    6670
  • trunk/src/libs/xpcom18a4/python/src/PyGBase.cpp

    r21178 r50710  
    196196{
    197197        NS_PRECONDITION(ppret!=NULL, "null pointer when wrapping a Python instance!");
    198         NS_PRECONDITION(ob && PyInstance_Check(ob), "AutoWrapPythonInstance is expecting an non-NULL instance!");
     198        NS_PRECONDITION(ob && PyObject_HasAttrString(ob, "__class__"),
     199                        "AutoWrapPythonInstance is expecting an non-NULL instance!");
    199200        PRBool ok = PR_FALSE;
    200201    // XXX - todo - this static object leaks! (but Python on Windows leaks 2000+ objects as it is ;-)
  • trunk/src/libs/xpcom18a4/python/src/PyIID.cpp

    r39535 r50710  
    115115        } else if (ob->ob_type == &type) {
    116116                iid = ((Py_nsIID *)ob)->m_iid;
    117         } else if (PyInstance_Check(ob)) {
     117        } else if (PyObject_HasAttrString(ob, "__class__")) {
    118118                // Get the _iidobj_ attribute
    119119                PyObject *use_ob = PyObject_GetAttrString(ob, "_iidobj_");
  • trunk/src/libs/xpcom18a4/python/src/PyISupports.cpp

    r50362 r50710  
    322322        if (iid.Equals(NS_GET_IID(nsIVariant)) || iid.Equals(NS_GET_IID(nsIWritableVariant))) {
    323323                // Check it is not already nsIVariant
    324                 if (PyInstance_Check(ob)) {
     324                if (PyObject_HasAttrString(ob, "__class__")) {
    325325                        PyObject *sub_ob = PyObject_GetAttrString(ob, "_comobj_");
    326326                        if (sub_ob==NULL) {
     
    345345        // end of variant support.
    346346
    347         if (PyInstance_Check(ob)) {
     347        if (PyObject_HasAttrString(ob, "__class__")) {
    348348                // Get the _comobj_ attribute
    349349                PyObject *use_ob = PyObject_GetAttrString(ob, "_comobj_");
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette