[IPython-user] Debugger.Pdb(OldPdb): __IPYTHON__ not defined causes crash
Peter J. Bismuti
peter.j.bismuti@boeing....
Sun Mar 16 08:32:17 CDT 2008
When I try to embed Python I get an exception __IPYTHON__ not found. It is
because Debugger.Pdb() forgets to set __IPYTHON__ in the "hack" copy of
__init__ (done to avoid importing 'readline'). Adding similar code from
above seems to have fixed it.
Is this any help?
-------[embed ipython within my code as per instructions]-----------
# Debug with IPython?
if (options.debugIPython):
try:
import sys,IPython.ultraTB
sys.excepthook = IPython.ultraTB.FormattedTB(mode='Verbose',
color_scheme='Linux', call_pdb=1)
except:
sys.stderr.write('Cant use IPython? That sucks!')
raise
-------[ADD NEW LINES TO Debugger.Pdb]-----------
else:
# Ugly hack: for Python 2.3-2.4, we can't call the parent constructor,
# because it binds readline and breaks tab-completion. This means we
# have to COPY the constructor here.
def __init__(self,color_scheme='NoColor'):
global __IPYTHON__
try:
__IPYTHON__
except NameError:
# Outside of ipython, we set our own exception hook manually
__IPYTHON__ = ipapi.get(True,False)
bdb.Bdb.__init__(self)
-------[otherwise, I get this when I try to embed]-----------
Error in sys.excepthook:
Traceback (most recent call last):
File "/acct/pjb9508/Python/local/lib/python/IPython/ultraTB.py", line 870,
in __call__
self.debugger()
File "/acct/pjb9508/Python/local/lib/python/IPython/ultraTB.py", line 847,
in debugger
self.pdb.interaction(self.tb.tb_frame, self.tb)
File "/acct/pjb9508/Python/local/lib/python/IPython/Debugger.py", line 293,
in interaction
__IPYTHON__.set_completer_frame(frame)
NameError: global name '__IPYTHON__' is not defined
--
Peter Bismuti
Boeing Information Technology
Renton, WA
(425) 234-0873 W
(425) 442-7775 C
More information about the IPython-user
mailing list