New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The getBaseObject function in is not compatible with python3 #823

tianzhuqiao opened this Issue Apr 20, 2018 · 0 comments


None yet
1 participant

tianzhuqiao commented Apr 20, 2018

The getBaseObject function in is not compatible with python3 (thus, no calltip is showing for class method).

According to python doc , to make the code work on python3 (>=2.6), obj.im_self should be replace with obj.__self__, and obj.im_func should be replaced with obj.__func__

def getBaseObject(obj):
    """Return base object and dropSelf indicator for an object."""
    if inspect.isbuiltin(obj):
        # Builtin functions don't have an argspec that we can get.
        dropSelf = 0
    elif inspect.ismethod(obj):
        # Get the function from the object otherwise
        # inspect.getargspec() complains that the object isn't a
        # Python function.
            if obj.im_self is None:
                # This is an unbound method so we do not drop self
                # from the argspec, since an instance must be passed
                # as the first arg.
                dropSelf = 0
                dropSelf = 1
            obj = obj.im_func
        except AttributeError:
            dropSelf = 0
    elif inspect.isclass(obj):
        # Get the __init__ method function for the class.
        constructor = getConstructor(obj)
        if constructor is not None:
            obj = constructor
            dropSelf = 1
            dropSelf = 0
    elif callable(obj):
        # Get the __call__ method instead.
            obj = obj.__call__.im_func
            dropSelf = 1
        except AttributeError:
            dropSelf = 0
        dropSelf = 0
return obj, dropSelf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment