summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2014-09-15 11:55:16 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2014-09-15 11:55:16 (GMT)
commita0f33759fa03a1801f25420e66fab3f2d938244d (patch)
tree296619b9eca5b00fb78a6360129d47ae7e522a60 /Python
parent0b894b40dba989d8ed3edff310859864748f8848 (diff)
parent8fad1676a215bab3e61dccf0f1802ccb17a43a41 (diff)
downloadcpython-a0f33759fa03a1801f25420e66fab3f2d938244d.zip
cpython-a0f33759fa03a1801f25420e66fab3f2d938244d.tar.gz
cpython-a0f33759fa03a1801f25420e66fab3f2d938244d.tar.bz2
Merge fix for issue #22166 from 3.4
Diffstat (limited to 'Python')
-rw-r--r--Python/codecs.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/Python/codecs.c b/Python/codecs.c
index 4c2ae38..faf1e92 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -185,6 +185,32 @@ PyObject *_PyCodec_Lookup(const char *encoding)
return NULL;
}
+int _PyCodec_Forget(const char *encoding)
+{
+ PyInterpreterState *interp;
+ PyObject *v;
+ int result;
+
+ interp = PyThreadState_GET()->interp;
+ 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)