def _lookupChainInFunction(self, pyFunction, chainWithPosition):
        freeVariable = chainWithPosition.var[0]

        if freeVariable in pyFunction.func_code.co_freevars:
            index = pyFunction.func_code.co_freevars.index(freeVariable)
            try:
                rootValue = pyFunction.__closure__[index].cell_contents
            except Exception as e:
                logging.error("Encountered Exception: %s: %s", type(e).__name__, e)
                logging.error(
                    "Failed to get value for free variable %s\n%s",
                    freeVariable, traceback.format_exc())
                raise UnresolvedFreeVariableException(
                    chainWithPosition, pyFunction.func_name)

        elif freeVariable in pyFunction.func_globals:
            rootValue = pyFunction.func_globals[freeVariable]

        elif hasattr(__builtin__, freeVariable):
            rootValue = getattr(__builtin__, freeVariable)

        else:
            raise UnresolvedFreeVariableException(
                chainWithPosition, pyFunction.func_name)

        return self._computeSubchainAndTerminalValueAlongModules(
            rootValue, chainWithPosition)
Test if methods detect their executable state correctly.
dataset/ETHPy150Open ufora/ufora/packages/python/pyfora/PyObjectWalker.py/PyObjectWalker._lookupChainInFunction--crossover with--dataset/ETHPy150Open T-002/pycast/pycast/tests/methodtest.py/BaseMethodTest.method_completition_test