summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-01-28 21:34:30 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-01-28 21:34:30 (GMT)
commit52716c94be3fa7b7df0160bc1cf5b04ec99f9c72 (patch)
treea36efdfd66f1001b2ad600f2e2570ec837dc8211 /Python
parentecdcb5895029c83c8bb5f98de502beaa56b78c9e (diff)
downloadcpython-52716c94be3fa7b7df0160bc1cf5b04ec99f9c72.zip
cpython-52716c94be3fa7b7df0160bc1cf5b04ec99f9c72.tar.gz
cpython-52716c94be3fa7b7df0160bc1cf5b04ec99f9c72.tar.bz2
Let marshal built-up sets and frozensets one element at a time (without creating an intermediate tuple).
Diffstat (limited to 'Python')
-rw-r--r--Python/marshal.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/Python/marshal.c b/Python/marshal.c
index 0c611b6..1b88ff9 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -860,7 +860,7 @@ r_object(RFILE *p)
retval = NULL;
break;
}
- v = PyTuple_New((int)n);
+ v = (type == TYPE_SET) ? PySet_New(NULL) : PyFrozenSet_New(NULL);
if (v == NULL) {
retval = NULL;
break;
@@ -875,18 +875,14 @@ r_object(RFILE *p)
v = NULL;
break;
}
- PyTuple_SET_ITEM(v, (int)i, v2);
+ if (PySet_Add(v, v2) == -1) {
+ Py_DECREF(v);
+ Py_DECREF(v2);
+ v = NULL;
+ break;
+ }
}
- if (v == NULL) {
- retval = NULL;
- break;
- }
- if (type == TYPE_SET)
- v3 = PySet_New(v);
- else
- v3 = PyFrozenSet_New(v);
- Py_DECREF(v);
- retval = v3;
+ retval = (v == NULL) ? NULL : v;
break;
case TYPE_CODE: