Rev 3980: Workaround a bug in pdb.post_mortem. (Andrew Bennetts) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Feb 4 04:58:12 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3980
revision-id: pqm at pqm.ubuntu.com-20090204045809-piqek6zlyl0x5ncw
parent: pqm at pqm.ubuntu.com-20090203220822-5duwp3g1fj9kc9qd
parent: andrew.bennetts at canonical.com-20090204041915-a57oazgobkmuce9e
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-02-04 04:58:09 +0000
message:
Workaround a bug in pdb.post_mortem. (Andrew Bennetts)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/commands.py bzr.py-20050309040720-d10f4714595cf8c3
------------------------------------------------------------
revno: 3978.1.3
revision-id: andrew.bennetts at canonical.com-20090204041915-a57oazgobkmuce9e
parent: andrew.bennetts at canonical.com-20090204041014-ny61o8sh69ee2nnw
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: pdb-workaround
timestamp: Wed 2009-02-04 15:19:15 +1100
message:
Add NEWS entry.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
------------------------------------------------------------
revno: 3978.1.2
revision-id: andrew.bennetts at canonical.com-20090204041014-ny61o8sh69ee2nnw
parent: andrew.bennetts at canonical.com-20090203055031-q0rde12116uv20t7
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: pdb-workaround
timestamp: Wed 2009-02-04 15:10:14 +1100
message:
Only use pdb.post_mortem workaround with Pythons older than 2.6.
modified:
bzrlib/commands.py bzr.py-20050309040720-d10f4714595cf8c3
------------------------------------------------------------
revno: 3978.1.1
revision-id: andrew.bennetts at canonical.com-20090203055031-q0rde12116uv20t7
parent: pqm at pqm.ubuntu.com-20090202091414-4q20mjzsvp03vyfc
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: pdb-workaround
timestamp: Tue 2009-02-03 16:50:31 +1100
message:
Add workaround for buggy pdb.post_mortem.
modified:
bzrlib/commands.py bzr.py-20050309040720-d10f4714595cf8c3
=== modified file 'NEWS'
--- a/NEWS 2009-01-31 04:17:43 +0000
+++ b/NEWS 2009-02-04 04:19:15 +0000
@@ -62,6 +62,11 @@
* Rule-based preferences can now accept multiple patterns for a set of
rules. (Marius Kruger)
+ * The debugger started as a result of setting ``$BZR_PDB`` works
+ around a bug in ``pdb``, http://bugs.python.org/issue4150. The bug
+ can cause truncated tracebacks in Python versions before 2.6.
+ (Andrew Bennetts)
+
* VirtualVersionedFiles now implements
``iter_lines_added_or_present_in_keys``. This allows the creation of
new branches based on stacked bzr-svn branches. (#311997)
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2008-12-16 07:56:29 +0000
+++ b/bzrlib/commands.py 2009-02-04 04:10:14 +0000
@@ -894,11 +894,32 @@
except (KeyboardInterrupt, Exception), e:
# used to handle AssertionError and KeyboardInterrupt
# specially here, but hopefully they're handled ok by the logger now
- exitcode = trace.report_exception(sys.exc_info(), sys.stderr)
+ exc_info = sys.exc_info()
+ exitcode = trace.report_exception(exc_info, sys.stderr)
if os.environ.get('BZR_PDB'):
print '**** entering debugger'
+ tb = exc_info[2]
import pdb
- pdb.post_mortem(sys.exc_traceback)
+ if sys.version_info[:2] < (2, 6):
+ # XXX: we want to do
+ # pdb.post_mortem(tb)
+ # but because pdb.post_mortem gives bad results for tracebacks
+ # from inside generators, we do it manually.
+ # (http://bugs.python.org/issue4150, fixed in Python 2.6)
+
+ # Setup pdb on the traceback
+ p = pdb.Pdb()
+ p.reset()
+ p.setup(tb.tb_frame, tb)
+ # Point the debugger at the deepest frame of the stack
+ p.curindex = len(p.stack) - 1
+ p.curframe = p.stack[p.curindex]
+ # Start the pdb prompt.
+ p.print_stack_entry(p.stack[p.curindex])
+ p.execRcLines()
+ p.cmdloop()
+ else:
+ pdb.post_mortem(tb)
return exitcode
More information about the bazaar-commits
mailing list