summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-10-25 06:06:13 +0000
committerGitHub <noreply@github.com>2020-10-25 06:06:13 +0000
commitb1c9a20f5d8961a5b1555cf68eb38afafb39e1d7 (patch)
treee5c3a1f5cddec8c49c94647d300a7ca2e76f191a /Python
parent4a9c6379380defd37b5483607d0d804db18f7812 (diff)
downloadcpython-git-revert-22513-update_test_codecs.tar.gz
Revert "bpo-41919, test_codecs: Move codecs.register calls to setUp() (GH-22513)"revert-22513-update_test_codecs
This reverts commit c9f696cb96d1c362d5cad871f61da520572d9b08.
Diffstat (limited to 'Python')
-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)