@@ -42,6 +42,12 @@ Copyright (c) Corporation for National Research Initiatives.
4242#include <windows.h>
4343#endif
4444
45+ /*[clinic input]
46+ module _codecs
47+ [clinic start generated code]*/
48+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=e1390e3da3cb9deb]*/
49+
50+
4551/* --- Registry ----------------------------------------------------------- */
4652
4753PyDoc_STRVAR (register__doc__ ,
@@ -138,6 +144,53 @@ codec_decode(PyObject *self, PyObject *args, PyObject *kwargs)
138144
139145/* --- Helpers ------------------------------------------------------------ */
140146
147+ /*[clinic input]
148+ _codecs._forget_codec
149+
150+ encoding: str
151+ /
152+
153+ Purge the named codec from the internal codec lookup cache
154+ [clinic start generated code]*/
155+
156+ PyDoc_STRVAR (_codecs__forget_codec__doc__ ,
157+ "_forget_codec($module, encoding, /)\n"
158+ "--\n"
159+ "\n"
160+ "Purge the named codec from the internal codec lookup cache" );
161+
162+ #define _CODECS__FORGET_CODEC_METHODDEF \
163+ {"_forget_codec", (PyCFunction)_codecs__forget_codec, METH_VARARGS, _codecs__forget_codec__doc__},
164+
165+ static PyObject *
166+ _codecs__forget_codec_impl (PyModuleDef * module , const char * encoding );
167+
168+ static PyObject *
169+ _codecs__forget_codec (PyModuleDef * module , PyObject * args )
170+ {
171+ PyObject * return_value = NULL ;
172+ const char * encoding ;
173+
174+ if (!PyArg_ParseTuple (args ,
175+ "s:_forget_codec" ,
176+ & encoding ))
177+ goto exit ;
178+ return_value = _codecs__forget_codec_impl (module , encoding );
179+
180+ exit :
181+ return return_value ;
182+ }
183+
184+ static PyObject *
185+ _codecs__forget_codec_impl (PyModuleDef * module , const char * encoding )
186+ /*[clinic end generated code: output=a75e631591702a5c input=18d5d92d0e386c38]*/
187+ {
188+ if (_PyCodec_Forget (encoding ) < 0 ) {
189+ return NULL ;
190+ };
191+ Py_RETURN_NONE ;
192+ }
193+
141194static
142195PyObject * codec_tuple (PyObject * unicode ,
143196 Py_ssize_t len )
@@ -1172,6 +1225,7 @@ static PyMethodDef _codecs_functions[] = {
11721225 register_error__doc__ },
11731226 {"lookup_error" , lookup_error , METH_VARARGS ,
11741227 lookup_error__doc__ },
1228+ _CODECS__FORGET_CODEC_METHODDEF
11751229 {NULL , NULL } /* sentinel */
11761230};
11771231
0 commit comments