add safety fix for Python globals in debug writer