ikpdb.py 文件源码

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

项目:ikpdb 作者: audaxis 项目源码 文件源码
def _runscript(self, filename):
        """ Launchs debugged program execution using the execfile() builtin.

        We reset and setup the __main__ dict to allow the script to run
        in __main__ namespace. This is required for imports from __main__ to 
        run correctly.

        Note that this has the effect to wipe IKPdb's vars created at this point.
        """
        import __main__
        __main__.__dict__.clear()
        __main__.__dict__.update({"__name__"    : "__main__",
                                  "__file__"    : filename,
                                  "__builtins__": __builtins__,})

        self.mainpyfile = self.canonic(filename)
        statement = 'execfile(%r)\n' % filename

        globals = __main__.__dict__
        locals = globals

        # When IKPdb sets tracing, a number of call and line events happens
        # BEFORE debugger even reaches user's code (and the exact sequence of
        # events depends on python version). So we take special measures to
        # avoid stopping before we reach the main script (see reset(),
        # _tracer() and _line_tracer() methods for details).
        self.reset()
        self.execution_started = True

        # Turn on limited tracing by setting trace function for 
        # current_thread only. This allow self.frame_beginning to be set at
        # first tracer "call" invocation.
        sys.settrace(self._tracer)

        try:
            exec(statement, globals, locals)
        except IKPdbQuit:
            pass
        finally:
            self.disable_tracing()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号