def run(self, cmd, fn=None, globals=None, locals=None):
        """Run the cmd `cmd` with trace"""
        if globals is None:
            import __main__
            globals = __main__.__dict__
        if locals is None:
            locals = globals
        self.reset()
        if isinstance(cmd, str):
            str_cmd = cmd
            cmd = compile(str_cmd, fn or "<wdb>", "exec")
            self.compile_cache[id(cmd)] = str_cmd
        if fn:
            from linecache import getline
            lno = 1
            while True:
                line = getline(fn, lno, globals)
                if line is None:
                    lno = None
                    break
                if executable_line(line):
                    break
                lno += 1

        self.start_trace()
        if lno is not None:
            self.breakpoints.add(LineBreakpoint(fn, lno, temporary=True))
        try:
            execute(cmd, globals, locals)
        finally:
            self.stop_trace()
def run ( self , cmd , fn = None , globals = None , locals = None ) : if globals is None : import __main__ globals = __main__ . __dict__ if locals is None : locals = globals self . reset ( ) if isinstance ( cmd , str ) : str_cmd = cmd cmd = compile ( str_cmd , fn or "<wdb>" , "exec" ) self . compile_cache [ id ( cmd ) ] = str_cmd if fn : from linecache import getline lno = 1 while True : line = getline ( fn , lno , globals ) if line is None : lno = None break if executable_line ( line ) : break lno += 1 self . start_trace ( ) if lno is not None : self . breakpoints . add ( LineBreakpoint ( fn , lno , temporary = True ) ) try : execute ( cmd , globals , locals ) finally : self . stop_trace ( )
Run the cmd `cmd` with trace