summaryrefslogtreecommitdiffstats
path: root/Modules/_struct.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-01-04 02:54:42 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-01-04 02:54:42 (GMT)
commit76d19f68e4c824bbcba890d924f20a6133ee0326 (patch)
tree3c2446dbe1a29d2bcbe3e28e9549cbb3608fd6ab /Modules/_struct.c
parentf2f41ebef48dcf5857f8522cca99be9464a3f3b4 (diff)
downloadcpython-76d19f68e4c824bbcba890d924f20a6133ee0326.zip
cpython-76d19f68e4c824bbcba890d924f20a6133ee0326.tar.gz
cpython-76d19f68e4c824bbcba890d924f20a6133ee0326.tar.bz2
Added _struct._clearcache() for regression tests
Diffstat (limited to 'Modules/_struct.c')
-rw-r--r--Modules/_struct.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c
index e3a8731..41cdca7 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -1851,11 +1851,11 @@ PyTypeObject PyStructType = {
/* ---- Standalone functions ---- */
#define MAXCACHE 100
+static PyObject *cache = NULL;
static PyObject *
cache_struct(PyObject *fmt)
{
- static PyObject *cache = NULL;
PyObject * s_object;
if (cache == NULL) {
@@ -1881,6 +1881,17 @@ cache_struct(PyObject *fmt)
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,
"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[] = {
+ {"_clearcache", (PyCFunction)clearcache, METH_NOARGS, clearcache_doc},
{"calcsize", calcsize, METH_O, calcsize_doc},
{"pack", pack, METH_VARARGS, pack_doc},
{"pack_into", pack_into, METH_VARARGS, pack_into_doc},