Bug 173258 - Python debugger can't cope with user exceptions
Python debugger can't cope with user exceptions
Status: NEW
Product: python
Classification: Unclassified
Component: Debugger
6.x
Sun Solaris
: P1 (vote)
: TBD
Assigned To: jymen
nbpythonqa
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-09-29 12:21 UTC by timf
Modified: 2009-10-27 14:22 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description timf 2009-09-29 12:21:24 UTC
I'm seeing odd behaviour with exception handling in Netbeans 6.7, with
slightly different failure cases depending on which python platform I used.
I was trying Jython 2.5 & Python 2.4.6. (Python 2.6.1 had the same 
failure cases as 2.4.6)

Using a brand new project, I created a simple python program:

=====
__author__="timf"
__date__ ="$Sep 29, 2009 11:25:05 AM$"

class MyException(Exception):
    pass

if __name__ == "__main__":
    print "Hello World";

    print "hello world"
    try:
        print "do stuff"
        raise MyException("something bad happened")
        print "won't get here"
    except MyException:
        print "Not to worry"
    print "ending here"
====

I set a breakpoint on the line just before the 'try:' statement, and
another on the 'print "not to worry"' line in the exception clause.


Using Jython 2.5 set as my project platform:

When running in the debugger we stop as expected on the first breakpoint.
Then, we click continue, expecting to hit the 2nd breakpoint, instead we get
the following crash in the debugger:

--------------------------------
[LOG]PythonDebugger : overall Starting
[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ...
[LOG]This window is an interactive debugging context aware Python Shell 
[LOG]where you can enter python console commands while debugging 
>>>/export/home/timf/.netbeans/6.7/config/nbPython/debug/nbpythondebug/jpydaemon.py
args =  ['/export/home/timf/.netbeans/6.7/config/nbPython/debug/nbpythondebug/jpydaemon.py', 'localhost', '29100']
localDebuggee= None
JPyDbg connecting  localhost  on in=  29100 /out= 29101
JPyDbgI0001 : connected to  localhost
>>>[stdout:]Hello World
[stdout:]hello world
>>>[stdout:]do stuffException in thread MainThread:Traceback (most recent call last):
  File "/export/home/timf/.netbeans/6.7/jython-2.5/Lib/threading.py", line 247, in _Thread__bootstrap
    self.run()
  File "/export/home/timf/.netbeans/6.7/config/nbPython/debug/nbpythondebug/jpydaemon.py", line 590, in run

    exec self._cmd in self._myglobals,self._mylocals
  File "<string>", line 1, in <module>
  File "/export/home/timf/NetBeansProjects/test/src/test.py", line 16, in <module>
    raise MyException("something bad happened")
Debug session normal end
  File "/export/home/timf/NetBeansProjects/test/src/test.py", line 16, in <module>
    raise MyException("something bad happened")
  File "/export/home/timf/.netbeans/6.7/config/nbPython/debug/nbpythondebug/jpydaemon.py", line 681, in trace_dispatch
    if not self.discardedException(arg) :
  File "/export/home/timf/.netbeans/6.7/config/nbPython/debug/nbpythondebug/jpydaemon.py", line 631, in discardedException
    tb  = exc_stuff[2]
IndexError: index out of range: 2
>>>
--------------------------------

Using Python 2.4.6 as the platform, we get similar behaviour - we stop on the
1st breakpoint, then crash before hitting the 2nd breakpoint:

--------------------------------
>>>[LOG]PythonDebugger : overall Starting
[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ...
[LOG]This window is an interactive debugging context aware Python Shell 
[LOG]where you can enter python console commands while debugging 
[stdout:]Hello World
[stdout:]hello world
>>>[stdout:]do stuff
Debug session normal end
something bad happened['Traceback (most recent call last):
/export/home/timf/.netbeans/6.7/config/nbPython/debug/nbpythondebug/jpydaemon.py
', '  File "/export/home/timf/NetBeansProjects/test/src/test.py", line 16, in ?
args =  ['/export/home/timf/.netbeans/6.7/config/nbPython/debug/nbpythondebug/jpydaemon.py', 'localhost', '29100']
    raise MyException("something bad happened")
', 'MyException: something bad happened
localDebuggee= None
']
JPyDbg connecting  localhost  on in=  29100 /out= 29101
JPyDbgI0001 : connected to  localhost
deamon ended

>>>
--------------------------------

Now, changing MyException to Exception (taking out the exception class declared here, 
and using the system-provided Exception implementation), we see different behaviour:

In Jython 2.5, we see that it hits the 1st exception, but then clicking continue
and expecting to hit the 2nd breakpoint, instead execution continues to the 
end of the program:

--------------------------------
>>>[LOG]PythonDebugger : overall Starting
[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ...
[LOG]This window is an interactive debugging context aware Python Shell 
[LOG]where you can enter python console commands while debugging 
>>>/export/home/timf/.netbeans/6.7/config/nbPython/debug/nbpythondebug/jpydaemon.py
args =  ['/export/home/timf/.netbeans/6.7/config/nbPython/debug/nbpythondebug/jpydaemon.py', 'localhost', '29100']
localDebuggee= None
JPyDbg connecting  localhost  on in=  29100 /out= 29101
JPyDbgI0001 : connected to  localhost
[stdout:]Hello World
[stdout:]hello world
>>>[stdout:]do stuff
[stdout:]Not to worry
[stdout:]ending here
Debug session normal end
--------------------------------

In Python 2.4.6, we see:

--------------------------------
[LOG]PythonDebugger : overall Starting
[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ...
[LOG]This window is an interactive debugging context aware Python Shell 
[LOG]where you can enter python console commands while debugging 
[stdout:]Hello World
[stdout:]hello world
>>>/export/home/timf/.netbeans/6.7/config/nbPython/debug/nbpythondebug/jpydaemon.py
[stdout:]do stuffargs =  ['/export/home/timf/.netbeans/6.7/config/nbPython/debug/nbpythondebug/jpydaemon.py',
'localhost', '29100']

localDebuggee= None
something bad happened['Traceback (most recent call last):
JPyDbg connecting  localhost  on in=  29100 /out= 29101
', '  File "/export/home/timf/NetBeansProjects/test/src/test.py", line 13, in ?
JPyDbgI0001 : connected to  localhost
    raise Exception("something bad happened")
deamon ended
', 'Exception: something bad happened

Not to worry
']
ending here
Debug session normal end
--------------------------------

I'm using 
Product Version: NetBeans IDE 6.7 (Build 200906241340)
Java: 1.6.0_15; Java HotSpot(TM) Client VM 14.1-b02
System: SunOS version 5.11 running on x86; UTF-8; en_US (nb)
Userdir: /export/home/timf/.netbeans/6.7

My Python plugin lists as:

Version: 0.101 Source: NetBeans Beta 

My Jython plugin lists as:

Version: 2.10 Source: NetBeans Beta  

Let me know if there's any other information I can provide?
Comment 1 timf 2009-09-29 12:38:06 UTC
Oh, I suspect this is completely the wrong thing to do, 
but found that if I just hacked out the contents of the
if-statement in:

~/.netbeans/6.7/config/nbPython/debug/nbpythondebug/jpydaemon.py

so that it would never fire at all, debugging would 'work' inside
exceptions (though again, perhaps this causes trouble down the line!)

 678         if event == 'exception':
 679             # set user exception info to be able to populate to client side later
 680             # mainDebugger.user_exception(frame,arg)
                 # Tim commented out this bit:
 681             #if not self.discardedException(arg) :
 682             #    mainDebugger.populate_exception(arg)
 683             #    mainDebugger.setTrace(None)
 684             #    # leave debuggee
 685             #    # raise BdbQuit
 686             #    mainDebugger.terminateDaemon()
 687             #    return None # stop trace on current frame
 688             return self.trace_dispatch
Comment 2 ardavis26 2009-10-27 14:21:29 UTC
I Traced this using ea 2 I was able to reproduce this issue on windows

Traceback follows:

[LOG]PythonDebugger : overall Starting
>>>[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ...
[LOG]This window is an interactive debugging context aware Python Shell 
[LOG]where you can enter python console commands while debugging 
>>>*sys-package-mgr*: processing new jar, 'C:\ADData\NetBeans 6.7.1\python1\jython-2.5\jython.jar'
>>>*sys-package-mgr*: processing new jar, 'C:\bea10\jdk150_15\jre\lib\rt.jar'
>>>*sys-package-mgr*: processing new jar, 'C:\bea10\jdk150_15\jre\lib\jsse.jar'
*sys-package-mgr*: processing new jar, 'C:\bea10\jdk150_15\jre\lib\jce.jar'
*sys-package-mgr*: processing new jar, 'C:\bea10\jdk150_15\jre\lib\charsets.jar'
>>>*sys-package-mgr*: processing new jar, 'C:\bea10\jdk150_15\jre\lib\ext\dnsns.jar'
*sys-package-mgr*: processing new jar, 'C:\bea10\jdk150_15\jre\lib\ext\localedata.jar'
*sys-package-mgr*: processing new jar, 'C:\bea10\jdk150_15\jre\lib\ext\sunjce_provider.jar'
*sys-package-mgr*: processing new jar, 'C:\bea10\jdk150_15\jre\lib\ext\sunpkcs11.jar'
>>>c:\documents and settings\davisal.mms\.netbeans\6.7\config\nbpython\debug\nbpythondebug\jpydaemon.py
args =  ['C:\\Documents and
Settings\\davisal.MMS\\.netbeans\\6.7\\config\\nbPython\\debug\\nbpythondebug\\jpydaemon.py', 'localhost', '29100']
localDebuggee= None
JPyDbg connecting  localhost  on in=  29100 /out= 29101
JPyDbgI0001 : connected to  localhost
>>>c:\documents and settings\davisal.mms\.netbeans\6.7\config\nbpython\debug\nbpythondebug\jpydaemon.py

>>>[LOG]PythonDebugger : overall Starting
[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ...
[LOG]This window is an interactive debugging context aware Python Shell 
[LOG]where you can enter python console commands while debugging 
>>>[LOG]PythonDebugger : overall Starting
>>>[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ...
[LOG]This window is an interactive debugging context aware Python Shell 
[LOG]where you can enter python console commands while debugging 
>>>[LOG]PythonDebugger : overall Starting
[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ...
[LOG]This window is an interactive debugging context aware Python Shell 
[LOG]where you can enter python console commands while debugging 
>>>c:\documents and settings\davisal.mms\.netbeans\6.7\config\nbpython\debug\nbpythondebug\jpydaemon.py
args =  ['C:\\Documents and
Settings\\davisal.MMS\\.netbeans\\6.7\\config\\nbPython\\debug\\nbpythondebug\\jpydaemon.py', 'localhost', '29115']
localDebuggee= None
JPyDbg connecting  localhost  on in=  29115 /out= 29116
JPyDbgI0001 : connected to  localhost
>>>[stdout:]Hello World
>>>[stdout:]hello world
>>>[stdout:]do stuff
>>>Exception in thread MainThread:Traceback (most recent call last):
  File "C:\ADData\NetBeans 6.7.1\python1\jython-2.5\Lib\threading.py", line 247, in _Thread__bootstrap
    self.run()
  File "C:\Documents and Settings\davisal.MMS\.netbeans\6.7\config\nbPython\debug\nbpythondebug\jpydaemon.py", line 590,
in run
    exec self._cmd in self._myglobals,self._mylocals
  File "<string>", line 1, in <module>
  File "C:/ADData/projects/pyDebugTest/src/pydebugtest.py", line 16, in <module>
    raise MyException("something bad happened")
  File "C:/ADData/projects/pyDebugTest/src/pydebugtest.py", line 16, in <module>
    raise MyException("something bad happened")
  File "C:\Documents and Settings\davisal.MMS\.netbeans\6.7\config\nbPython\debug\nbpythondebug\jpydaemon.py", line 681,
in trace_dispatch
    if not self.discardedException(arg) :
  File "C:\Documents and Settings\davisal.MMS\.netbeans\6.7\config\nbPython\debug\nbpythondebug\jpydaemon.py", line 631,
in discardedException
    tb  = exc_stuff[2]
IndexError: index out of range: 2
>>>Debug session normal end
[LOG]PythonDebugger : overall Starting
[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ...
[LOG]This window is an interactive debugging context aware Python Shell 
[LOG]where you can enter python console commands while debugging 
>>>c:\documents and settings\davisal.mms\.netbeans\6.7\config\nbpython\debug\nbpythondebug\jpydaemon.py
args =  ['C:\\Documents and
Settings\\davisal.MMS\\.netbeans\\6.7\\config\\nbPython\\debug\\nbpythondebug\\jpydaemon.py', 'localhost', '29115']
localDebuggee= None
JPyDbg connecting  localhost  on in=  29115 /out= 29116
JPyDbgI0001 : connected to  localhost
>>>[stdout:]Hello World
>>>[stdout:]hello world
>>>[stdout:]do stuff
>>>[stdout:]Not to worry
[stdout:]ending here
Debug session normal end
[LOG]PythonDebugger : overall Starting
[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ...
[LOG]This window is an interactive debugging context aware Python Shell 
[LOG]where you can enter python console commands while debugging 
>>>c:\documents and settings\davisal.mms\.netbeans\6.7\config\nbpython\debug\nbpythondebug\jpydaemon.py
args =  ['C:\\Documents and
Settings\\davisal.MMS\\.netbeans\\6.7\\config\\nbPython\\debug\\nbpythondebug\\jpydaemon.py', 'localhost', '29115']
localDebuggee= None
JPyDbg connecting  localhost  on in=  29115 /out= 29116
JPyDbgI0001 : connected to  localhost
>>>[stdout:]Hello World
>>>[stdout:]hello world
>>>[stdout:]do stuff
>>>Exception in thread MainThread:Traceback (most recent call last):
  File "C:\ADData\NetBeans 6.7.1\python1\jython-2.5\Lib\threading.py", line 247, in _Thread__bootstrap
    self.run()
  File "C:\Documents and Settings\davisal.MMS\.netbeans\6.7\config\nbPython\debug\nbpythondebug\jpydaemon.py", line 590,
in run
    exec self._cmd in self._myglobals,self._mylocals
  File "<string>", line 1, in <module>
  File "C:/ADData/projects/pyDebugTest/src/pydebugtest.py", line 16, in <module>
    raise MyException("something bad happened")
  File "C:/ADData/projects/pyDebugTest/src/pydebugtest.py", line 16, in <module>
    raise MyException("something bad happened")
  File "C:\Documents and Settings\davisal.MMS\.netbeans\6.7\config\nbPython\debug\nbpythondebug\jpydaemon.py", line 681,
in trace_dispatch
    if not self.discardedException(arg) :
  File "C:\Documents and Settings\davisal.MMS\.netbeans\6.7\config\nbPython\debug\nbpythondebug\jpydaemon.py", line 631,
in discardedException
    tb  = exc_stuff[2]
Debug session normal end
IndexError: index out of range: 2
>>> 


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo