Extended _is_number check to support older versions of gmpy