@value.setter
    def value(self, value):
        if self._invalid:
            raise ValueError(
                'The value of invalid/unparseable cards cannot set.  Either '
                'delete this card from the header or replace it.')

        if value is None:
            value = ''
        oldvalue = self._value
        if oldvalue is None:
            oldvalue = ''

        if not isinstance(value, string_types + integer_types +
                                 (float, complex, bool, Undefined, np.floating,
                                  np.integer, np.complexfloating, np.bool_)):
            raise ValueError('Illegal value: %r.' % value)

        if isinstance(value, float) and (np.isnan(value) or np.isinf(value)):
            raise ValueError(
                "Floating point %r values are not allowed in FITS headers." %
                value)
        elif isinstance(value, text_type):
            m = self._ascii_text_re.match(value)
            if not m:
                raise ValueError(
                    'FITS header values must contain standard printable ASCII '
                    'characters; %r contains characters not representable in '
                    'ASCII or non-printable characters.' % value)
        elif isinstance(value, binary_type):
            # Allow str, but only if they can be decoded to ASCII text; note
            # this is not even allowed on Python 3 since the `bytes` type is
            # not included in `six.string_types`.  Presently we simply don't
            # allow bytes to be assigned to headers, as doing so would too
            # easily mask potential user error
            valid = True
            try:
                text_value = value.decode('ascii')
            except UnicodeDecodeError:
                valid = False
            else:
                # Check against the printable characters regexp as well
                m = self._ascii_text_re.match(text_value)
                valid = m is not None

            if not valid:
                raise ValueError(
                    'FITS header values must contain standard printable ASCII '
                    'characters; %r contains characters/bytes that do not '
                    'represent printable characters in ASCII.' % value)
        elif isinstance(value, np.bool_):
            value = bool(value)

        if (pyfits.STRIP_HEADER_WHITESPACE and
            (isinstance(oldvalue, string_types) and
             isinstance(value, string_types))):
            # Ignore extra whitespace when comparing the new value to the old
            different = oldvalue.rstrip() != value.rstrip()
        elif isinstance(oldvalue, bool) or isinstance(value, bool):
            different = oldvalue is not value
        else:
            different = (oldvalue != value or
                         not isinstance(value, type(oldvalue)))

        if different:
            self._value = value
            self._rawvalue = None
            self._modified = True
            self._valuestring = None
            self._valuemodified = True
            if self.field_specifier:
                try:
                    self._value = _int_or_float(self._value)
                except __HOLE__:
                    raise ValueError('value %s is not a float' %
                                     self._value)
dataset/ETHPy150Open spacetelescope/PyFITS/pyfits/card.py/Card.value