summaryrefslogtreecommitdiffstats
path: root/Modules/cPickle.c
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-04-07 06:33:21 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2008-04-07 06:33:21 (GMT)
commitc20adf8ef2d9ec938069d08fdcf66cff1d4a6905 (patch)
tree41872a64c0efdbe7ae55b94f09a07b7313a50b8f /Modules/cPickle.c
parentd918e4e068f22c3e79c771c27be3c8f91a9e0446 (diff)
downloadcpython-c20adf8ef2d9ec938069d08fdcf66cff1d4a6905.zip
cpython-c20adf8ef2d9ec938069d08fdcf66cff1d4a6905.tar.gz
cpython-c20adf8ef2d9ec938069d08fdcf66cff1d4a6905.tar.bz2
Use the new PyFile_IncUseCount & PyFile_DecUseCount calls appropriatly
within the standard library. These modules use PyFile_AsFile and later release the GIL while operating on the previously returned FILE*.
Diffstat (limited to 'Modules/cPickle.c')
-rw-r--r--Modules/cPickle.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index 2a05c06..b9b95c8 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -431,9 +431,11 @@ write_file(Picklerobject *self, const char *s, Py_ssize_t n)
return -1;
}
+ PyFile_IncUseCount((PyFileObject *)self->file);
Py_BEGIN_ALLOW_THREADS
nbyteswritten = fwrite(s, sizeof(char), n, self->fp);
Py_END_ALLOW_THREADS
+ PyFile_DecUseCount((PyFileObject *)self->file);
if (nbyteswritten != (size_t)n) {
PyErr_SetFromErrno(PyExc_IOError);
return -1;
@@ -542,9 +544,11 @@ read_file(Unpicklerobject *self, char **s, Py_ssize_t n)
self->buf_size = n;
}
+ PyFile_IncUseCount((PyFileObject *)self->file);
Py_BEGIN_ALLOW_THREADS
nbytesread = fread(self->buf, sizeof(char), n, self->fp);
Py_END_ALLOW_THREADS
+ PyFile_DecUseCount((PyFileObject *)self->file);
if (nbytesread != (size_t)n) {
if (feof(self->fp)) {
PyErr_SetNone(PyExc_EOFError);