sys.settrace() and Python 2.3

Josiah Carlson jcarlson at uci.edu
Wed Jun 28 18:37:06 EDT 2006


According to my reading of Python 2.3 docs, the call to goo() at the end
should exit with a KeyboardInterrupt...

    import sys

    def goo():
        while 1:
            pass

    count = [100]
    def foo(frame, event, arg):
        count[0] -= 1
        if not count[0]:
            raise KeyboardInterrupt
        return foo

    sys.settrace(foo)

    goo()

In Python 2.3, the above call to goo() doesn't seem to ever return.  It
exits with a KeyboardInterrupt in 2.4, as expected.  Does anyone have an
idea why this is the case?  I've checked the release notes for both 2.3
and 2.4 and found no discussion of trace functions in them or
sourceforge (I could be entering in the wrong terms, of course).

Any pointers as to why there is a difference would be appreciated. 
Thank you,
 - Josiah

(I'm not subscribed, but I'll be checking for replies, and ccing me on
any replies would be appreciated)




More information about the Python-list mailing list