mirror of
https://github.com/python/cpython.git
synced 2025-11-03 11:23:31 +00:00
SF bug [ #233200 ] cPickle does not use Py_BEGIN_ALLOW_THREADS.
http://sourceforge.net/tracker/?func=detail&aid=233200&group_id=5470&atid=105470 Wrapped the fread/fwrite calls in thread BEGIN_ALLOW/END_ALLOW brackets Afraid I hit the "delete trailing whitespace key" too! Only two "real" sections of code changed here.
This commit is contained in:
parent
d179be8b8b
commit
84e87f379e
1 changed files with 182 additions and 173 deletions
|
|
@ -403,11 +403,16 @@ cPickle_ErrFormat(PyObject *ErrType, char *stringformat, char *format, ...)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
write_file(Picklerobject *self, char *s, int n) {
|
write_file(Picklerobject *self, char *s, int n) {
|
||||||
|
size_t nbyteswritten;
|
||||||
|
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fwrite(s, sizeof(char), n, self->fp) != (size_t)n) {
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
nbyteswritten = fwrite(s, sizeof(char), n, self->fp);
|
||||||
|
Py_END_ALLOW_THREADS
|
||||||
|
if (nbyteswritten != (size_t)n) {
|
||||||
PyErr_SetFromErrno(PyExc_IOError);
|
PyErr_SetFromErrno(PyExc_IOError);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -482,6 +487,7 @@ write_other(Picklerobject *self, char *s, int n) {
|
||||||
|
|
||||||
static int
|
static int
|
||||||
read_file(Unpicklerobject *self, char **s, int n) {
|
read_file(Unpicklerobject *self, char **s, int n) {
|
||||||
|
size_t nbytesread;
|
||||||
|
|
||||||
if (self->buf_size == 0) {
|
if (self->buf_size == 0) {
|
||||||
int size;
|
int size;
|
||||||
|
|
@ -503,7 +509,10 @@ read_file(Unpicklerobject *self, char **s, int n) {
|
||||||
self->buf_size = n;
|
self->buf_size = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fread(self->buf, sizeof(char), n, self->fp) != (size_t)n) {
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
nbytesread = fread(self->buf, sizeof(char), n, self->fp);
|
||||||
|
Py_END_ALLOW_THREADS
|
||||||
|
if (nbytesread != (size_t)n) {
|
||||||
if (feof(self->fp)) {
|
if (feof(self->fp)) {
|
||||||
PyErr_SetNone(PyExc_EOFError);
|
PyErr_SetNone(PyExc_EOFError);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue