~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-30 14:18:22 UTC
  • mfrom: (6456 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6464.
  • Revision ID: jelmer@samba.org-20120130141822-u4fqwswoyew4a14a
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
794
794
            (1, 17))
795
795
        self.add_hook('pre_command',
796
796
            "Called prior to executing a command. Called with the command "
797
 
            "object.", (2, 6))
 
797
            "object.", (2, 5))
798
798
        self.add_hook('post_command',
799
799
            "Called after executing a command. Called with the command "
800
 
            "object.", (2, 6))
 
800
            "object.", (2, 5))
801
801
 
802
802
Command.hooks = CommandHooks()
803
803
 
935
935
        exitcode = trace.report_exception(exc_info, sys.stderr)
936
936
        if os.environ.get('BZR_PDB'):
937
937
            print '**** entering debugger'
 
938
            tb = exc_info[2]
938
939
            import pdb
939
 
            pdb.post_mortem(exc_info[2])
 
940
            if sys.version_info[:2] < (2, 6):
 
941
                # XXX: we want to do
 
942
                #    pdb.post_mortem(tb)
 
943
                # but because pdb.post_mortem gives bad results for tracebacks
 
944
                # from inside generators, we do it manually.
 
945
                # (http://bugs.python.org/issue4150, fixed in Python 2.6)
 
946
 
 
947
                # Setup pdb on the traceback
 
948
                p = pdb.Pdb()
 
949
                p.reset()
 
950
                p.setup(tb.tb_frame, tb)
 
951
                # Point the debugger at the deepest frame of the stack
 
952
                p.curindex = len(p.stack) - 1
 
953
                p.curframe = p.stack[p.curindex][0]
 
954
                # Start the pdb prompt.
 
955
                p.print_stack_entry(p.stack[p.curindex])
 
956
                p.execRcLines()
 
957
                p.cmdloop()
 
958
            else:
 
959
                pdb.post_mortem(tb)
940
960
        return exitcode
941
961
 
942
962