

def get_func_code(func):
    " Attempts to retrieve a reliable function code hash.\n\n        The reason we don't use inspect.getsource is that it caches the\n        source, whereas we want this to be modified on the fly when the\n        function is modified.\n\n        Returns\n        -------\n        func_code: string\n            The function code\n        source_file: string\n            The path to the file in which the function is defined.\n        first_line: int\n            The first line of the code in the source file.\n\n        Notes\n        ------\n        This function does a bit more magic than inspect, and is thus\n        more robust.\n    "
    source_file = None
    try:
        code = func.__code__
        source_file = code.co_filename
        if (not os.path.exists(source_file)):
            source_code = ''.join(inspect.getsourcelines(func)[0])
            line_no = 1
            if source_file.startswith('<doctest '):
                (source_file, line_no) = re.match('\\<doctest (.*\\.rst)\\[(.*)\\]\\>', source_file).groups()
                line_no = int(line_no)
                source_file = ('<doctest %s>' % source_file)
            return (source_code, source_file, line_no)
        with open_py_source(source_file) as source_file_obj:
            first_line = code.co_firstlineno
            source_lines = list(islice(source_file_obj, (first_line - 1), None))
        return (''.join(inspect.getblock(source_lines)), source_file, source_file_obj)
    except:
        if hasattr(func, '__code__'):
            return (str(func.__code__.__hash__()), source_file, (- 1))
        else:
            return (repr(func), source_file, (- 1))

dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/externals/joblib/func_inspect.py get_func_code/VarMisuse@174/493 `first_line`->`source_file_obj`