summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-04-21 20:49:36 (GMT)
committerGuido van Rossum <guido@python.org>2000-04-21 20:49:36 (GMT)
commit83addc7a0f7371ccb28c5fd3b090556b505d8a69 (patch)
tree3298052c99b11c70b2fd54563380746c918ba694 /Modules
parent2dd8dddef412c64692f2ba6eb297411a00ff5d29 (diff)
downloadcpython-83addc7a0f7371ccb28c5fd3b090556b505d8a69.zip
cpython-83addc7a0f7371ccb28c5fd3b090556b505d8a69.tar.gz
cpython-83addc7a0f7371ccb28c5fd3b090556b505d8a69.tar.bz2
Charles Waldman writes:
""" Problem description: Run the following script: import test.test_cpickle for x in xrange(1000000): reload(test.test_cpickle) Watch Python's memory use go up up and away! In the course of debugging this I also saw that cPickle is inconsistent with pickle - if you attempt a pickle.load or pickle.dump on a closed file, you get a ValueError, whereas the corresponding cPickle operations give an IOError. Since cPickle is advertised as being compatible with pickle, I changed these exceptions to match. """
Diffstat (limited to 'Modules')
-rw-r--r--Modules/cPickle.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index ecf941d..aa2c7cb 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -2151,19 +2151,18 @@ newPicklerobject(PyObject *file, int bin) {
Py_INCREF(file);
else
file=Pdata_New();
+
+ UNLESS (self->file = file)
+ goto err;
- self->file = file;
-
- UNLESS (self->memo = PyDict_New()) {
- Py_XDECREF((PyObject *)self);
- return NULL;
- }
+ UNLESS (self->memo = PyDict_New())
+ goto err;
if (PyFile_Check(file)) {
self->fp = PyFile_AsFile(file);
if (self->fp == NULL) {
- PyErr_SetString(PyExc_IOError, "output file closed");
- return NULL;
+ PyErr_SetString(PyExc_ValueError, "I/O operation on closed file");
+ goto err;
}
self->write_func = write_file;
}
@@ -4054,10 +4053,8 @@ newUnpicklerobject(PyObject *f) {
self->safe_constructors = NULL;
self->find_class = NULL;
- UNLESS (self->memo = PyDict_New()) {
- Py_XDECREF((PyObject *)self);
- return NULL;
- }
+ UNLESS (self->memo = PyDict_New())
+ goto err;
Py_INCREF(f);
self->file = f;
@@ -4066,8 +4063,8 @@ newUnpicklerobject(PyObject *f) {
if (PyFile_Check(f)) {
self->fp = PyFile_AsFile(f);
if (self->fp == NULL) {
- PyErr_SetString(PyExc_IOError, "input file closed");
- return NULL;
+ PyErr_SetString(PyExc_ValueError, "I/O operation on closed file");
+ goto err;
}
self->read_func = read_file;
self->readline_func = readline_file;