Beispiel #1
0
    def user_line(self, frame):
        """This function is called when we stop or break at this line.
        However it's *also* called when line OR function tracing is 
        in effect. A little bit confusing and this code needs to be 
        simplified."""
        self.stop_reason = 'line'
        if self._wait_for_mainpyfile:
            if (self.mainpyfile != self.canonic_filename(frame)
                    or inspect.getlineno(frame) <= 0):
                return
            self._wait_for_mainpyfile = False

        if self.stop_here(frame) or self.linetrace or self.fntrace:
            # Don't stop if we are looking at a def for which a breakpoint
            # has not been set.
            filename = frame2file(self, frame)

            # Python 2.5 or greater has 3 arg getline which handles
            # eggs and zip files
            if 3 == linecache.getline.func_code.co_argcount:
                line = linecache.getline(filename, inspect.getlineno(frame),
                                         frame.f_globals)
            else:
                line = linecache.getline(filename, inspect.getlineno(frame))
                pass

            # No, we don't have a breakpoint. So we are either
            # stepping or here because of line tracing.
            if self.step_ignore > 0:
                # Don't stop this time, just note a step was done in
                # step count
                self.step_ignore -= 1
                self.__print_location_if_trace(frame, False)

                return
            elif self.step_ignore < 0:
                # We are stepping only because we tracing
                self.__print_location_if_trace(frame, False)
                return
            if not self.break_here(frame):
                if bytecode.is_def_stmt(line, frame) and not self.deftrace:
                    self.__print_location_if_trace(frame, False)
                    return
                elif self.fntrace:
                    # The above test is a real hack. We need to clean
                    # up this code.
                    return
        else:
            if not self.break_here(frame) and self.step_ignore > 0:
                self.__print_location_if_trace(frame, False)
                self.step_ignore -= 1
                return
        if self.bp_commands(frame):
            self.interaction(frame, None)
            return
        return
Beispiel #2
0
    def user_line(self, frame):
        """This function is called when we stop or break at this line.
        However it's *also* called when line OR function tracing is 
        in effect. A little bit confusing and this code needs to be 
        simplified."""
        self.stop_reason = 'line'
        if self._wait_for_mainpyfile:
            if (self.mainpyfile != self.canonic_filename(frame)
                or inspect.getlineno(frame) <= 0):
                return
            self._wait_for_mainpyfile = False

        if self.stop_here(frame) or self.linetrace or self.fntrace:
            # Don't stop if we are looking at a def for which a breakpoint
            # has not been set.
            filename = frame2file(self, frame)

            # Python 2.5 or greater has 3 arg getline which handles
            # eggs and zip files
            if 3 == linecache.getline.func_code.co_argcount:
                line = linecache.getline(filename, inspect.getlineno(frame),
                                         frame.f_globals)
            else:
                line = linecache.getline(filename, inspect.getlineno(frame))
                pass

            # No, we don't have a breakpoint. So we are either
            # stepping or here because of line tracing.
            if self.step_ignore > 0:
                # Don't stop this time, just note a step was done in
                # step count
                self.step_ignore -= 1
                self.__print_location_if_trace(frame, False)
                return
            elif self.step_ignore < 0:
                # We are stepping only because we tracing
                self.__print_location_if_trace(frame, False)
                return
            if not self.break_here(frame):
                if bytecode.is_def_stmt(line, frame) and not self.deftrace:
                    self.__print_location_if_trace(frame, False)
                    return
                elif self.fntrace:
                    # The above test is a real hack. We need to clean
                    # up this code. 
                    return
        else:
            if not self.break_here(frame) and self.step_ignore > 0:
                self.__print_location_if_trace(frame, False)
                self.step_ignore -= 1
                return
        if self.bp_commands(frame):
            self.interaction(frame, None)
            return
        return
Beispiel #3
0
 def test_is_def_frame(self):
     # Not a "def" statement because frame is wrong spot
     frame = inspect.currentframe()
     self.assertFalse(is_def_stmt('foo(): pass', frame))
     return