@@ -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__ ,
@@ -134,6 +140,53 @@ codec_decode(PyObject *self, PyObject *args)
134140
135141/* --- Helpers ------------------------------------------------------------ */
136142
143+ /*[clinic input]
144+ _codecs._forget_codec
145+
146+ encoding: str
147+ /
148+
149+ Purge the named codec from the internal codec lookup cache
150+ [clinic start generated code]*/
151+
152+ PyDoc_STRVAR (_codecs__forget_codec__doc__ ,
153+ "_forget_codec($module, encoding, /)\n"
154+ "--\n"
155+ "\n"
156+ "Purge the named codec from the internal codec lookup cache" );
157+
158+ #define _CODECS__FORGET_CODEC_METHODDEF \
159+ {"_forget_codec", (PyCFunction)_codecs__forget_codec, METH_VARARGS, _codecs__forget_codec__doc__},
160+
161+ static PyObject *
162+ _codecs__forget_codec_impl (PyModuleDef * module , const char * encoding );
163+
164+ static PyObject *
165+ _codecs__forget_codec (PyModuleDef * module , PyObject * args )
166+ {
167+ PyObject * return_value = NULL ;
168+ const char * encoding ;
169+
170+ if (!PyArg_ParseTuple (args ,
171+ "s:_forget_codec" ,
172+ & encoding ))
173+ goto exit ;
174+ return_value = _codecs__forget_codec_impl (module , encoding );
175+
176+ exit :
177+ return return_value ;
178+ }
179+
180+ static PyObject *
181+ _codecs__forget_codec_impl (PyModuleDef * module , const char * encoding )
182+ /*[clinic end generated code: output=a75e631591702a5c input=18d5d92d0e386c38]*/
183+ {
184+ if (_PyCodec_Forget (encoding ) < 0 ) {
185+ return NULL ;
186+ };
187+ Py_RETURN_NONE ;
188+ }
189+
137190static
138191PyObject * codec_tuple (PyObject * unicode ,
139192 Py_ssize_t len )
@@ -1168,6 +1221,7 @@ static PyMethodDef _codecs_functions[] = {
11681221 register_error__doc__ },
11691222 {"lookup_error" , lookup_error , METH_VARARGS ,
11701223 lookup_error__doc__ },
1224+ _CODECS__FORGET_CODEC_METHODDEF
11711225 {NULL , NULL } /* sentinel */
11721226};
11731227
0 commit comments