summaryrefslogtreecommitdiff
path: root/Python/codecs.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/codecs.c')
-rw-r--r--Python/codecs.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/Python/codecs.c b/Python/codecs.c
index ade1418720..a8233a73c4 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -208,6 +208,31 @@ PyObject *_PyCodec_Lookup(const char *encoding)
return NULL;
}
+int _PyCodec_Forget(const char *encoding)
+{
+ PyObject *v;
+ int result;
+
+ PyInterpreterState *interp = _PyInterpreterState_GET();
+ if (interp->codec_search_path == NULL) {
+ return -1;
+ }
+
+ /* Convert the encoding to a normalized Python string: all
+ characters are converted to lower case, spaces and hyphens are
+ replaced with underscores. */
+ v = normalizestring(encoding);
+ if (v == NULL) {
+ return -1;
+ }
+
+ /* Drop the named codec from the internal cache */
+ result = PyDict_DelItem(interp->codec_search_cache, v);
+ Py_DECREF(v);
+
+ return result;
+}
+
/* Codec registry encoding check API. */
int PyCodec_KnownEncoding(const char *encoding)