def set_reason(self, reason):
if reason is None:<EOL><INDENT>self._delete_reason()<EOL><DEDENT>elif not isinstance(reason, bytes):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>reason = reason.lower().replace(b'<STR_LIT:U+0020>', b'<STR_LIT>')<EOL>reason_code = [r.lower() for r in self._crl_reasons].index(reason)<EOL>new_reason_ext = _lib.ASN1_ENUMERATED_new()<EOL>_openssl_assert(new_reason_ext != _ffi.NULL)<EOL>new_reason_ext = _ffi.gc(new_reason_ext, _lib.ASN1_ENUMERATED_free)<EOL>set_result = _lib.ASN1_ENUMERATED_set(new_reason_ext, reason_code)<EOL>_openssl_assert(set_result != _ffi.NULL)<EOL>self._delete_reason()<EOL>add_result = _lib.X509_REVOKED_add1_ext_i2d(<EOL>self._revoked, _lib.NID_crl_reason, new_reason_ext, <NUM_LIT:0>, <NUM_LIT:0>)<EOL>_openssl_assert(add_result == <NUM_LIT:1>)<EOL><DEDENT>
Set the reason of this revocation.

If :data:`reason` is ``None``, delete the reason instead.

:param reason: The reason string.
:type reason: :class:`bytes` or :class:`NoneType`

:return: ``None``

.. seealso::

    :meth:`all_reasons`, which gives you a list of all supported
    reasons which you might pass to this method.