Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Andrea <mariofutire <at> googlemail.com>
Subject: Bug in sys.settrace?
Newsgroups: gmane.comp.lang.jython.user
Date: Friday 24th July 2009 20:08:52 UTC (over 8 years ago)
Hi,

I've managed to reproduce the bug in the debugger in NetBeans

===============================================
import sys

def printTrace(frame, event, arg):
     if (event == 'exception'):
         print arg
         print 'Arg size=', len(arg)
         print arg[2]   # <<<<<<<<<<<<<<<<<<<<<<< THIS FAILS EVEN IF
len(arg)==3
     return printTrace

def foo():
     print 'Here foo'

sys.settrace(printTrace)
foo()

import threading

try:
     dir(pippo)
except:
     print "Error caught"

The output is

Here foo
(, None, null)
Arg size= 3
(, 'index out of range: 2', )
Arg size= 3

(, 'index out of range: 2', )
Arg size= 3

Traceback (most recent call last):
   File "/home/andrea/foo/j.py", line 16, in 
     import threading
   File "/home/andrea/projects/java/jython2.5.0/Lib/threading.py", line 12,
in 
     from traceback import print_exc as _print_exc
   File "/home/andrea/projects/java/jython2.5.0/Lib/traceback.py", line 5,
in 
     import types
   File "/home/andrea/projects/java/jython2.5.0/Lib/types.py", line 54, in

     GeneratorType = type(g())
   File "/home/andrea/foo/j.py", line 7, in printTrace
     print arg[2]
IndexError: index out of range: 2


Reading http://docs.python.org/library/sys.html,
the 3rd argument (arg), for the event='exception' 
should have 3 values, and indeed there are 3 values, but the last is "null"
which seems to cause 
problems.
Sometimes though the 3 values are ok.

Cheers

Andrea


------------------------------------------------------------------------------
 
CD: 3ms