mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-41842: Add codecs.unregister() function (GH-22360)
Add codecs.unregister() and PyCodec_Unregister() functions to unregister a codec search function.
This commit is contained in:
parent
24ba3b0df5
commit
d332e7b816
11 changed files with 108 additions and 5 deletions
|
|
@ -68,6 +68,27 @@ _codecs_register(PyObject *module, PyObject *search_function)
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_codecs.unregister
|
||||
search_function: object
|
||||
/
|
||||
|
||||
Unregister a codec search function and clear the registry's cache.
|
||||
|
||||
If the search function is not registered, do nothing.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_codecs_unregister(PyObject *module, PyObject *search_function)
|
||||
/*[clinic end generated code: output=1f0edee9cf246399 input=dd7c004c652d345e]*/
|
||||
{
|
||||
if (PyCodec_Unregister(search_function) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_codecs.lookup
|
||||
encoding: str
|
||||
|
|
@ -992,6 +1013,7 @@ _codecs_lookup_error_impl(PyObject *module, const char *name)
|
|||
|
||||
static PyMethodDef _codecs_functions[] = {
|
||||
_CODECS_REGISTER_METHODDEF
|
||||
_CODECS_UNREGISTER_METHODDEF
|
||||
_CODECS_LOOKUP_METHODDEF
|
||||
_CODECS_ENCODE_METHODDEF
|
||||
_CODECS_DECODE_METHODDEF
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue