mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Added _struct._clearcache() for regression tests
This commit is contained in:
parent
f2f41ebef4
commit
76d19f68e4
3 changed files with 15 additions and 1 deletions
|
@ -1 +1,2 @@
|
||||||
from _struct import *
|
from _struct import *
|
||||||
|
from _struct import _clearcache
|
||||||
|
|
|
@ -729,6 +729,7 @@ def dash_R_cleanup(fs, ps, pic, abcs):
|
||||||
linecache.clearcache()
|
linecache.clearcache()
|
||||||
mimetypes._default_mime_types()
|
mimetypes._default_mime_types()
|
||||||
filecmp._cache.clear()
|
filecmp._cache.clear()
|
||||||
|
struct._clearcache()
|
||||||
doctest.master = None
|
doctest.master = None
|
||||||
|
|
||||||
# Collect cyclic trash.
|
# Collect cyclic trash.
|
||||||
|
|
|
@ -1851,11 +1851,11 @@ PyTypeObject PyStructType = {
|
||||||
/* ---- Standalone functions ---- */
|
/* ---- Standalone functions ---- */
|
||||||
|
|
||||||
#define MAXCACHE 100
|
#define MAXCACHE 100
|
||||||
|
static PyObject *cache = NULL;
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
cache_struct(PyObject *fmt)
|
cache_struct(PyObject *fmt)
|
||||||
{
|
{
|
||||||
static PyObject *cache = NULL;
|
|
||||||
PyObject * s_object;
|
PyObject * s_object;
|
||||||
|
|
||||||
if (cache == NULL) {
|
if (cache == NULL) {
|
||||||
|
@ -1881,6 +1881,17 @@ cache_struct(PyObject *fmt)
|
||||||
return s_object;
|
return s_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(clearcache_doc,
|
||||||
|
"Clear the internal cache.");
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
clearcache(PyObject *self)
|
||||||
|
{
|
||||||
|
if (cache != NULL)
|
||||||
|
PyDict_Clear(cache);
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(calcsize_doc,
|
PyDoc_STRVAR(calcsize_doc,
|
||||||
"Return size of C struct described by format string fmt.");
|
"Return size of C struct described by format string fmt.");
|
||||||
|
|
||||||
|
@ -2006,6 +2017,7 @@ unpack_from(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct PyMethodDef module_functions[] = {
|
static struct PyMethodDef module_functions[] = {
|
||||||
|
{"_clearcache", (PyCFunction)clearcache, METH_NOARGS, clearcache_doc},
|
||||||
{"calcsize", calcsize, METH_O, calcsize_doc},
|
{"calcsize", calcsize, METH_O, calcsize_doc},
|
||||||
{"pack", pack, METH_VARARGS, pack_doc},
|
{"pack", pack, METH_VARARGS, pack_doc},
|
||||||
{"pack_into", pack_into, METH_VARARGS, pack_into_doc},
|
{"pack_into", pack_into, METH_VARARGS, pack_into_doc},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue