summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-09-07 14:35:37 (GMT)
committerGuido van Rossum <guido@python.org>2000-09-07 14:35:37 (GMT)
commitebba420285990ab01973765eea03498eab170ae7 (patch)
treed3a952a23e8c1d88af4e3d247cedba737f240119 /Modules
parent6300bd42a40428df6b49780a5b47da1ad0c7eab2 (diff)
downloadcpython-ebba420285990ab01973765eea03498eab170ae7.zip
cpython-ebba420285990ab01973765eea03498eab170ae7.tar.gz
cpython-ebba420285990ab01973765eea03498eab170ae7.tar.bz2
Oops. Jim's fix didn't. This one does -- I tested it a bit better
this time!
Diffstat (limited to 'Modules')
-rw-r--r--Modules/cPickle.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index 7161c2e..2466465 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -4386,7 +4386,7 @@ static struct PyMethodDef cPickle_methods[] = {
};
static int
-init_stuff(PyObject *module, PyObject *module_dict) {
+init_stuff(PyObject *module_dict) {
PyObject *string, *copy_reg, *t, *r;
#define INIT_STR(S) UNLESS(S ## _str=PyString_FromString(#S)) return -1;
@@ -4516,17 +4516,23 @@ init_stuff(PyObject *module, PyObject *module_dict) {
#endif
DL_EXPORT(void)
initcPickle(void) {
- PyObject *m, *d, *v;
+ PyObject *m, *d, *di, *v, *k;
+ int i;
char *rev="1.71";
PyObject *format_version;
PyObject *compatible_formats;
- if (init_stuff(m, d) < 0) return;
-
Picklertype.ob_type = &PyType_Type;
Unpicklertype.ob_type = &PyType_Type;
PdataType.ob_type = &PyType_Type;
+ /* Initialize some pieces. We need to do this before module creation,
+ so we're forced to use a temporary dictionary. :(
+ */
+ di=PyDict_New();
+ if (!di) return;
+ if (init_stuff(di) < 0) return;
+
/* Create the module and add the functions */
m = Py_InitModule4("cPickle", cPickle_methods,
cPickle_module_documentation,
@@ -4537,6 +4543,15 @@ initcPickle(void) {
PyDict_SetItemString(d,"__version__", v = PyString_FromString(rev));
Py_XDECREF(v);
+ /* Copy data from di. Waaa. */
+ for (i=0; PyDict_Next(di, &i, &k, &v); ) {
+ if (PyObject_SetItem(d, k, v) < 0) {
+ Py_DECREF(di);
+ return;
+ }
+ }
+ Py_DECREF(di);
+
format_version = PyString_FromString("1.3");
compatible_formats = Py_BuildValue("[sss]", "1.0", "1.1", "1.2");