python: fixed TypeError on some python version