mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #22166: clear codec caches in test_codecs
This commit is contained in:
parent
b85a97600a
commit
8fad1676a2
5 changed files with 102 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue