summaryrefslogtreecommitdiffstats
path: root/Modules/_codecsmodule.c
diff options
context:
space:
mode:
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>2024-09-29 00:25:23 (GMT)
committerGitHub <noreply@github.com>2024-09-29 00:25:23 (GMT)
commitc00964ecd508ba6ae43498017d5a3873844a058a (patch)
tree5a31d8510a4e248d98bc60f473b6b95116263f21 /Modules/_codecsmodule.c
parent04c837d9d8a474777ef9c1412fbba14f0682366c (diff)
downloadcpython-c00964ecd508ba6ae43498017d5a3873844a058a.zip
cpython-c00964ecd508ba6ae43498017d5a3873844a058a.tar.gz
cpython-c00964ecd508ba6ae43498017d5a3873844a058a.tar.bz2
gh-124665: Add `_PyCodec_UnregisterError` and `_codecs._unregister_error` (#124677)
Diffstat (limited to 'Modules/_codecsmodule.c')
-rw-r--r--Modules/_codecsmodule.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 32373f0..471b42b 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -980,6 +980,30 @@ _codecs_register_error_impl(PyObject *module, const char *errors,
}
/*[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 */
};