Fix instance check, on some versions of Python