Example #1
0
    def inject_default_namespace(self, stackframe=None):
        """
        Adds the default namespace to the frame, or if no frame is provided,
        self.curframe is used.
        """
        stackframe = stackframe or self.curframe
        to_remove = set()
        for k, v in items(self.default_namespace):
            if k not in stackframe.f_globals:
                # Only add the default things if the name is unbound.
                stackframe.f_globals[k] = v
                to_remove.add(k)

        try:
            yield stackframe
        finally:
            for k in to_remove:
                try:
                    del stackframe.f_globals[k]
                except IndexError:
                    # The body of this manager might have del'd this.
                    pass

            # Prevent exceptions from generating ref cycles.
            del stackframe
Example #2
0
File: tracer.py Project: zw1226/qdb
    def inject_default_namespace(self, stackframe=None):
        """
        Adds the default namespace to the frame, or if no frame is provided,
        self.curframe is used.
        """
        stackframe = stackframe or self.curframe
        to_remove = set()
        for k, v in items(self.default_namespace):
            if k not in stackframe.f_globals:
                # Only add the default things if the name is unbound.
                stackframe.f_globals[k] = v
                to_remove.add(k)

        try:
            yield stackframe
        finally:
            for k in to_remove:
                try:
                    del stackframe.f_globals[k]
                except IndexError:
                    # The body of this manager might have del'd this.
                    pass

            # Prevent exceptions from generating ref cycles.
            del stackframe
Example #3
0
 def __new__(mcls, name, bases, dict_):
     return super(Py2TestMeta, mcls).__new__(
         mcls,
         name,
         bases,
         {k: skip_py3(v) if k.startswith('test_') else v
          for k, v in items(dict_)}
     )
Example #4
0
File: comm.py Project: OspreyX/qdb
 def send_watchlist(self, tracer):
     """
     Sends the watchlist event.
     """
     self.send_event(
         'watchlist',
         [{'expr': k, 'exc': exc, 'value': val}
          for k, (exc, val) in items(tracer.watchlist)],
     )
Example #5
0
File: comm.py Project: wixb50/qdb
 def send_watchlist(self, tracer):
     """
     Sends the watchlist event.
     """
     self.send_event(
         'watchlist',
         [{'expr': k, 'exc': exc, 'value': val}
          for k, (exc, val) in items(tracer.watchlist)],
     )
Example #6
0
File: comm.py Project: OspreyX/qdb
    def do_locals(self, arg, tracer):
        """
        locals
        Report back the current stackframe's locals.
        """
        self.writeln('locals: [')
        for p in items(tracer.curframe_locals):
            self.writeln('  %s=%s' % p)
        self.writeln(']')

        return self.next_command.tailcall(tracer)
Example #7
0
    def do_locals(self, arg, tracer):
        """
        locals
        Report back the current stackframe's locals.
        """
        self.writeln('locals: [')
        for p in items(tracer.curframe_locals):
            self.writeln('  %s=%s' % p)
        self.writeln(']')

        return self.next_command.tailcall(tracer)
Example #8
0
 def __new__(mcls, name, bases, dict_):
     return super(Py2TestMeta, mcls).__new__(
         mcls, name, bases, {
             k: skip_py3(v) if k.startswith('test_') else v
             for k, v in items(dict_)
         })