[MERGE] Don't automatically use psyco as a side-effect of importing bzrlib.util.bencode
Andrew Bennetts
andrew at canonical.com
Fri Mar 16 01:22:16 GMT 2007
Hi all,
If you have psyco installed, then with current bzr.dev pdb is broken. You can
easily reproduce this by doing:
python -c "import bzrlib.util.bencode; import pdb; pdb.set_trace()"
This will just exit without starting pdb. Compare to:
python -c "import pdb; pdb.set_trace()"
This is obviously extremely frustrating if you want to insert a breakpoint in a
failing test.
The reason why it happens is because psyco wraps some native frame objects
with its own frame objects that outwardly behave very similarly. This seems to
happen even on apparently unrelated code paths. pdb internally uses "is" to
compare frame objects, so psyco breaks it, tricking pdb into thinking there are
no frames of interest to it on the stack. I suspect pdb could be changed to use
"==" without any ill effect, but for now we're stuck with it as it is.
So this bundle prevents the importing of psyco by default. If we do decide to
use psyco, we should probably provide a command-line option or some other way to
disable it easily for when we want to use a debugger, rather than
unconditionally using it when it is available.
Finally, I'd like to say that debugging a debugger is no fun :)
-Andrew.
-------------- next part --------------
# Bazaar revision bundle v0.9
#
# message:
# Don't use automatically use psyco just by importing a module. It has the nasty side-effect of breaking pdb.
# committer: Andrew Bennetts <andrew.bennetts at canonical.com>
# date: Fri 2007-03-16 12:08:28.505000114 +1100
=== modified file bzrlib/util/bencode.py
--- bzrlib/util/bencode.py
+++ bzrlib/util/bencode.py
@@ -320,9 +320,3 @@
return
assert 0
-try:
- import psyco
- psyco.bind(bdecode)
- psyco.bind(bencode)
-except ImportError:
- pass
=== modified directory // last-changed:andrew.bennetts at canonical.com-200703160
... 10828-1o6m7ec9n9mtr3lx
# revision id: andrew.bennetts at canonical.com-20070316010828-1o6m7ec9n9mtr3lx
# sha1: 1e178cd1195b1173b428bd6831662d7224e9fb30
# inventory sha1: 0471b17cc0c9884af07292603423c9231eb16963
# parent ids:
# pqm at pqm.ubuntu.com-20070315231915-000d2bef502ae12b
# base id: pqm at pqm.ubuntu.com-20070315231915-000d2bef502ae12b
# properties:
# branch-nick: dont-use-psyco
More information about the bazaar
mailing list