def findsource(pyObject):

    pyFile = getfile(pyObject)
    sourcefile = getsourcefile(pyObject)

    if not sourcefile and pyFile[:1] + pyFile[-1:] != '<>':
        raise IOError('source code not available')

    pyFile = sourcefile if sourcefile else file

    module = getmodule(pyObject, pyFile)
    lines = getlines(pyFile)
    if not lines:
        raise IOError('could not get source code')

    if ismodule(pyObject):
        return lines, 0

    if isclass(pyObject):
        name = pyObject.__name__
        pat = re.compile(r'^(\s*)class\s*' + name + r'\b')
        # find all matching class definitions and if more than one
        # is found, raise a PyforaInspectError
        candidates = []
        for i in range(len(lines)):
            match = pat.match(lines[i])
            if match:
                # add to candidate list
                candidates.append(i)
        if not candidates:
            raise IOError('could not find class definition for %s' % pyObject)
        elif len(candidates) > 1:
            raise PyforaInspectError('could not find class unequivocally: class ' + name)
        else:
            # classes may have decorators and the decorator is considered part
            # of the class definition
            lnum = candidates[0]
            pat = re.compile(r'^(\s*)@\w+')
            while lnum > 0 and pat.match(lines[lnum-1]):
                lnum -= 1
            return lines, lnum

    if ismethod(pyObject):
        pyObject = pyObject.im_func
    if isfunction(pyObject):
        pyObject = pyObject.func_code
    if istraceback(pyObject):
        pyObject = pyObject.tb_frame
    if isframe(pyObject):
        pyObject = pyObject.f_code
    if iscode(pyObject):
        if pyFile == "<stdin>":
            #the "co_firstlineno" variable is wrong in this case.
            #we need to find the actual line number
            lnum = StdinCache.singleton().refreshFromReadline().findCodeLineNumberWithinStdin(pyObject)
        else:
            if not hasattr(pyObject, 'co_firstlineno'):
                raise IOError('could not find function definition')
            lnum = pyObject.co_firstlineno - 1
        pat = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)')
        while lnum > 0:
            if pat.match(lines[lnum]): break
            lnum = lnum - 1
        return lines, lnum
    raise IOError('could not find code object')

# ---------------- unmodified code (from inspect.py in the python2.7 distribution)
Constructor.
dataset/ETHPy150Open ufora/ufora/packages/python/pyfora/PyforaInspect.py/findsource--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/ext/mapreduce/model.py/JsonProperty.__init__