summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-12-15 21:47:57 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-12-15 21:47:57 (GMT)
commit31949b9108088b1ad0efd9d518029b6980b191e9 (patch)
tree7c544636e9bb4d88d8b8214e339f88e78be23257 /Modules
parent68060013eaa13ddd26bf4eb804d3dce7b29813a9 (diff)
downloadcpython-31949b9108088b1ad0efd9d518029b6980b191e9.zip
cpython-31949b9108088b1ad0efd9d518029b6980b191e9.tar.gz
cpython-31949b9108088b1ad0efd9d518029b6980b191e9.tar.bz2
#3954: Fix error handling code in _hotshot.logreader
Will port to 2.6. hotshot was deleted from python 3.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_hotshot.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/Modules/_hotshot.c b/Modules/_hotshot.c
index 4c66e2a..a36cd50 100644
--- a/Modules/_hotshot.c
+++ b/Modules/_hotshot.c
@@ -1357,20 +1357,16 @@ hotshot_logreader(PyObject *unused, PyObject *args)
self->logfp = fopen(filename, "rb");
if (self->logfp == NULL) {
PyErr_SetFromErrnoWithFilename(PyExc_IOError, filename);
- Py_DECREF(self);
- self = NULL;
- goto finally;
+ goto error;
}
self->info = PyDict_New();
- if (self->info == NULL) {
- Py_DECREF(self);
- goto finally;
- }
+ if (self->info == NULL)
+ goto error;
/* read initial info */
for (;;) {
if ((c = fgetc(self->logfp)) == EOF) {
eof_error(self);
- break;
+ goto error;
}
if (c != WHAT_ADD_INFO) {
ungetc(c, self->logfp);
@@ -1383,13 +1379,15 @@ hotshot_logreader(PyObject *unused, PyObject *args)
else
PyErr_SetString(PyExc_RuntimeError,
"unexpected error");
- break;
+ goto error;
}
}
}
}
- finally:
return (PyObject *) self;
+ error:
+ Py_DECREF(self);
+ return NULL;
}