summaryrefslogtreecommitdiff
path: root/Modules/_codecsmodule.c
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2014-09-15 23:50:44 +1200
committerNick Coghlan <ncoghlan@gmail.com>2014-09-15 23:50:44 +1200
commit8fad1676a215bab3e61dccf0f1802ccb17a43a41 (patch)
tree8a372bcba4c55571779e527d4c202bc2ab04ea0b /Modules/_codecsmodule.c
parentb85a97600a45bf235fd8b541ebab358f6a8aa5dd (diff)
downloadcpython-git-8fad1676a215bab3e61dccf0f1802ccb17a43a41.tar.gz
Issue #22166: clear codec caches in test_codecs
Diffstat (limited to 'Modules/_codecsmodule.c')
-rw-r--r--Modules/_codecsmodule.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 0b093ab19f..11d376883d 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -42,6 +42,12 @@ Copyright (c) Corporation for National Research Initiatives.
#include <windows.h>
#endif
+/*[clinic input]
+module _codecs
+[clinic start generated code]*/
+/*[clinic end generated code: output=da39a3ee5e6b4b0d input=e1390e3da3cb9deb]*/
+
+
/* --- Registry ----------------------------------------------------------- */
PyDoc_STRVAR(register__doc__,
@@ -134,6 +140,53 @@ codec_decode(PyObject *self, PyObject *args)
/* --- Helpers ------------------------------------------------------------ */
+/*[clinic input]
+_codecs._forget_codec
+
+ encoding: str
+ /
+
+Purge the named codec from the internal codec lookup cache
+[clinic start generated code]*/
+
+PyDoc_STRVAR(_codecs__forget_codec__doc__,
+"_forget_codec($module, encoding, /)\n"
+"--\n"
+"\n"
+"Purge the named codec from the internal codec lookup cache");
+
+#define _CODECS__FORGET_CODEC_METHODDEF \
+ {"_forget_codec", (PyCFunction)_codecs__forget_codec, METH_VARARGS, _codecs__forget_codec__doc__},
+
+static PyObject *
+_codecs__forget_codec_impl(PyModuleDef *module, const char *encoding);
+
+static PyObject *
+_codecs__forget_codec(PyModuleDef *module, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ const char *encoding;
+
+ if (!PyArg_ParseTuple(args,
+ "s:_forget_codec",
+ &encoding))
+ goto exit;
+ return_value = _codecs__forget_codec_impl(module, encoding);
+
+exit:
+ return return_value;
+}
+
+static PyObject *
+_codecs__forget_codec_impl(PyModuleDef *module, const char *encoding)
+/*[clinic end generated code: output=a75e631591702a5c input=18d5d92d0e386c38]*/
+{
+ if (_PyCodec_Forget(encoding) < 0) {
+ return NULL;
+ };
+ Py_RETURN_NONE;
+}
+
static
PyObject *codec_tuple(PyObject *unicode,
Py_ssize_t len)
@@ -1168,6 +1221,7 @@ static PyMethodDef _codecs_functions[] = {
register_error__doc__},
{"lookup_error", lookup_error, METH_VARARGS,
lookup_error__doc__},
+ _CODECS__FORGET_CODEC_METHODDEF
{NULL, NULL} /* sentinel */
};