code.py 文件源码

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

项目:zippy 作者: securesystemslab 项目源码 文件源码
def showtraceback(self):
        """Display the exception that just occurred.

        We remove the first stack item because it is our own code.

        The output is written by self.write(), below.

        """
        sys.last_type, sys.last_value, last_tb = ei = sys.exc_info()
        sys.last_traceback = last_tb
        try:
            lines = []
            for value, tb in traceback._iter_chain(*ei[1:]):
                if isinstance(value, str):
                    lines.append(value)
                    lines.append('\n')
                    continue
                if tb:
                    tblist = traceback.extract_tb(tb)
                    if tb is last_tb:
                        # The last traceback includes the frame we
                        # exec'd in
                        del tblist[:1]
                    tblines = traceback.format_list(tblist)
                    if tblines:
                        lines.append("Traceback (most recent call last):\n")
                        lines.extend(tblines)
                lines.extend(traceback.format_exception_only(type(value),
                                                             value))
        finally:
            tblist = last_tb = ei = None
        self.write(''.join(lines))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号