log.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:xcsvm 作者: albermax 项目源码 文件源码
def findCaller(self):
            """
            Find the stack frame of the caller so that we can note the source
            file name, line number and function name.
            """
            f = sys._getframe(3)
            # On some versions of IronPython, currentframe() returns None if
            # IronPython isn't run with -X:Frames.
            if f is not None:
                f = f.f_back

            _srcfiles = [os.path.normcase(__file__),
                         logging._srcfile]

            rv = "(unknown file)", 0, "(unknown function)"
            while hasattr(f, "f_code"):
                co = f.f_code
                filename = os.path.normcase(co.co_filename)
                if filename in _srcfiles:
                    f = f.f_back
                    continue
                rv = (co.co_filename, f.f_lineno, co.co_name)
                break
            return rv
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号