Python 3 fixes for tf extension module (no more global state version)