I knew I had overlooked at least one thing... :) To see if there is a current Python thread state at all, you can not use PyThreadState_GET in a debug build... (because if there isn't one, Python aborts). But _PyThreadState_Current is a global variable that you can check directly. Hans