Issue1412

classification
Title: Bad arguments to settrace callback upon exception
Type: behaviour Severity: normal
Components: Core Versions: 2.5.0
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: audetto, fwierzbicki, thobes
Priority: Keywords:

Created on 2009-07-26.15:18:28 by audetto, last changed 2012-01-03.00:36:40 by fwierzbicki.

Files
File name Uploaded Description Edit Remove
j.py audetto, 2009-07-26.15:26:18 Example of the bug
Messages
msg4947 (view) Author: Andrea (audetto) Date: 2009-07-26.15:26:18
The callback passed to sys.settrace is (sometimes) called with a bad 3rd
argument when an exception occurs.

According to
http://docs.python.org/library/sys.html

when there is an exception, arg is a tuple with 3 values.
In this case arg is

(<type 'exceptions.GeneratorExit'>, None, null)

and accessing arg[2] causes an error.

IndexError: index out of range: 2

I am not sure but the fact that arg[2] is "null" and not "None" might be
linked.
msg4948 (view) Author: Andrea (audetto) Date: 2009-07-26.15:27:08
This is the output with jython

Here foo
(<type 'exceptions.GeneratorExit'>, None, null)
Arg size= 3
(<type 'exceptions.IndexError'>, 'index out of range: 2', <traceback
object at 0x1>)
Arg size= 3
<traceback object at 0x1>
(<type 'exceptions.IndexError'>, 'index out of range: 2', <traceback
object at 0x2>)
Arg size= 3
<traceback object at 0x2>
Traceback (most recent call last):
  File "/home/andrea/foo/j.py", line 16, in <module>
    import threading
  File "/home/andrea/projects/java/jython2.5.0/Lib/threading.py", line
12, in <module>
    from traceback import print_exc as _print_exc
  File "/home/andrea/projects/java/jython2.5.0/Lib/traceback.py", line
5, in <module>
    import types
  File "/home/andrea/projects/java/jython2.5.0/Lib/types.py", line 54,
in <module>
    GeneratorType = type(g())
  File "/home/andrea/foo/j.py", line 7, in printTrace
    print arg[2]
IndexError: index out of range: 2
msg4949 (view) Author: Andrea (audetto) Date: 2009-07-26.15:28:33
And this with python 2.6

Here foo
(<type 'exceptions.AttributeError'>, '_release_save', <traceback object
at 0xb7d48f2c>)
Arg size= 3
<traceback object at 0xb7d48f2c>
(<type 'exceptions.AttributeError'>, '_acquire_restore', <traceback
object at 0xb7d48fcc>)
Arg size= 3
<traceback object at 0xb7d48fcc>
(<type 'exceptions.AttributeError'>, '_is_owned', <traceback object at
0xb7d48f04>)
Arg size= 3
<traceback object at 0xb7d48f04>
(<type 'exceptions.AttributeError'>, '_release_save', <traceback object
at 0xb7d48fa4>)
Arg size= 3
<traceback object at 0xb7d48fa4>
(<type 'exceptions.AttributeError'>, '_acquire_restore', <traceback
object at 0xb7d48f7c>)
Arg size= 3
<traceback object at 0xb7d48f7c>
(<type 'exceptions.AttributeError'>, '_is_owned', <traceback object at
0xb7d48fcc>)
Arg size= 3
<traceback object at 0xb7d48fcc>
Error caught
msg4976 (view) Author: Andrea (audetto) Date: 2009-07-31.19:40:39
I've analyzed it a bit more and here is my result

http://article.gmane.org/gmane.comp.lang.jython.user/8055
msg4981 (view) Author: Tobias Ivarsson (thobes) Date: 2009-08-04.01:02:05
Fix checked into rev6628:
http://jython.svn.sourceforge.net/viewvc/jython?view=rev&revision=6628

Thanks to Andrea for Patch.

We should add a regression test for this.
msg5129 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2009-09-09.20:02:49
This is proving tough to get into a unit test today, assigning it to
myself to give it a try another day.
msg6752 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-01-03.00:36:40
Closing as this is fixed and I haven't gotten around to putting a test in place for too long.
History
Date User Action Args
2012-01-03 00:36:40fwierzbickisetstatus: open -> closed
resolution: fixed
messages: + msg6752
2009-09-09 20:02:49fwierzbickisetassignee: fwierzbicki
messages: + msg5129
nosy: + fwierzbicki
2009-08-04 01:02:05thobessetnosy: + thobes
messages: + msg4981
2009-07-31 19:40:39audettosetmessages: + msg4976
2009-07-26 15:28:33audettosetmessages: + msg4949
2009-07-26 15:27:09audettosetmessages: + msg4948
2009-07-26 15:26:18audettosetfiles: + j.py
messages: + msg4947
2009-07-26 15:18:28audettocreate