Tcl/tk error in python

In python, if the tcl package is not compiled with the threads option, if it runs a tcl/tk application, it will crash with the following error at the end:
TclError: out of stack space (infinite loop?)

To reproduce this, just run the pydoc.gui() program:

import pydoc
pydoc.gui()

This problem will affect pyraf and prevent it from loading. To fix this, compile the tcl package with --enable-threads or in macports, install the thread variant: port install tcl +threads.