Commit 0567421a authored by Kevin Modzelewski's avatar Kevin Modzelewski

The _struct module caches things internally

parent c483a729
...@@ -1819,6 +1819,7 @@ cache_struct(PyObject *fmt) ...@@ -1819,6 +1819,7 @@ cache_struct(PyObject *fmt)
cache = PyDict_New(); cache = PyDict_New();
if (cache == NULL) if (cache == NULL)
return NULL; return NULL;
PyGC_RegisterStaticConstant(cache);
} }
s_object = PyDict_GetItem(cache, fmt); s_object = PyDict_GetItem(cache, fmt);
...@@ -1844,6 +1845,9 @@ PyDoc_STRVAR(clearcache_doc, ...@@ -1844,6 +1845,9 @@ PyDoc_STRVAR(clearcache_doc,
static PyObject * static PyObject *
clearcache(PyObject *self) clearcache(PyObject *self)
{ {
// `cache` is already registered as a static root; we would need to unregister it.
Py_FatalError("_struct.clearcache dosen't currently work well with Pyston");
abort();
Py_CLEAR(cache); Py_CLEAR(cache);
Py_RETURN_NONE; Py_RETURN_NONE;
} }
......
# expected: reffail
import gzip import gzip
import io import io
......
# expected: reffail
from StringIO import StringIO from StringIO import StringIO
import json import json
......
# expected: reffail
import struct import struct
s = struct.pack("II", 1, 1234) s = struct.pack("II", 1, 1234)
print repr(s) print repr(s)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment