gh-124665: Add _PyCodec_UnregisterError and _codecs._unregister_error (#124677)

This commit is contained in:
Bénédikt Tran 2024-09-29 02:25:23 +02:00 committed by GitHub
parent 04c837d9d8
commit c00964ecd5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 136 additions and 2 deletions

View file

@ -979,6 +979,30 @@ _codecs_register_error_impl(PyObject *module, const char *errors,
Py_RETURN_NONE;
}
/*[clinic input]
_codecs._unregister_error -> bool
errors: str
/
Un-register the specified error handler for the error handling `errors'.
Only custom error handlers can be un-registered. An exception is raised
if the error handling is a built-in one (e.g., 'strict'), or if an error
occurs.
Otherwise, this returns True if a custom handler has been successfully
un-registered, and False if no custom handler for the specified error
handling exists.
[clinic start generated code]*/
static int
_codecs__unregister_error_impl(PyObject *module, const char *errors)
/*[clinic end generated code: output=28c22be667465503 input=a63ab9e9ce1686d4]*/
{
return _PyCodec_UnregisterError(errors);
}
/*[clinic input]
_codecs.lookup_error
name: str
@ -1044,6 +1068,7 @@ static PyMethodDef _codecs_functions[] = {
_CODECS_CODE_PAGE_ENCODE_METHODDEF
_CODECS_CODE_PAGE_DECODE_METHODDEF
_CODECS_REGISTER_ERROR_METHODDEF
_CODECS__UNREGISTER_ERROR_METHODDEF
_CODECS_LOOKUP_ERROR_METHODDEF
{NULL, NULL} /* sentinel */
};