[xiph-cvs] cvs commit: vorbis-python/src pyvorbisfile.c pyvorbisinfo.c
Andrew Chatham Master of Python
andrew at xiph.org
Mon Sep 8 20:40:48 PDT 2003
andrew 03/09/08 23:40:48
Modified: . ChangeLog
src pyvorbisfile.c pyvorbisinfo.c
Log:
2003-09-08 Andrew H. Chatham <pyogg at andrewchatham.com>
* pyvorbisfile.c, pyvorbisinfo.c: Fix an exception leak (the
exceptions would show up later, even though things worked OK)
Revision Changes Path
1.24 +4 -0 vorbis-python/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/ChangeLog,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- ChangeLog 1 Sep 2003 23:30:26 -0000 1.23
+++ ChangeLog 9 Sep 2003 03:40:47 -0000 1.24
@@ -1,3 +1,7 @@
+2003-09-08 Andrew H. Chatham <pyogg at andrewchatham.com>
+ * pyvorbisfile.c, pyvorbisinfo.c: Fix an exception leak (the
+ exceptions would show up later, even though things worked OK)
+
2003-9-01 Andrew H. Chatham <pyogg at andrewchatham.com>
* pyvorbisfile.c (py_ov_file_dealloc) Fix a file descriptor leak.
<p><p>1.13 +23 -22 vorbis-python/src/pyvorbisfile.c
Index: pyvorbisfile.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/src/pyvorbisfile.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- pyvorbisfile.c 1 Sep 2003 23:30:26 -0000 1.12
+++ pyvorbisfile.c 9 Sep 2003 03:40:48 -0000 1.13
@@ -217,36 +217,37 @@
return NULL;
}
- } else if (PyArg_ParseTuple(args, "O!|sl", &PyFile_Type, &fobject,
- &initial, &ibytes)) {
+ } else {
PyErr_Clear(); /* clear first failure */
+ if (PyArg_ParseTuple(args, "O!|sl", &PyFile_Type, &fobject,
+ &initial, &ibytes)) {
+
+ fname = NULL;
+ file = PyFile_AsFile(fobject);
+ if (!file)
+ return NULL;
- fname = NULL;
- file = PyFile_AsFile(fobject);
- if (file) {
/* We have to duplicate the file descriptor, since both Python
- and vorbisfile will want to close it. Don't use the file
- after you pass it in, or much evil will occur.
-
- Really, you shouldn't be passing in files anymore, but in the
- interest of backwards compatibility it'll stay.
+ and vorbisfile will want to close it. Don't use the file
+ after you pass it in, or much evil will occur.
+
+ Really, you shouldn't be passing in files anymore, but in the
+ interest of backwards compatibility it'll stay.
*/
int orig_fd, new_fd;
orig_fd = fileno(file);
new_fd = dup(orig_fd);
file = fdopen(new_fd, "r");
if (!file) {
- PyErr_SetString(PyExc_IOError, "Could not duplicate file.");
- return NULL;
+ PyErr_SetString(PyExc_IOError, "Could not duplicate file.");
+ return NULL;
}
} else {
+ PyErr_Clear(); /* clear first failure */
+ PyErr_SetString(PyExc_TypeError,
+ "Argument 1 is not a filename or file object");
return NULL;
}
-
- } else {
- PyErr_SetString(PyExc_TypeError,
- "Argument 1 is not a filename or file object");
- return NULL;
}
self->ovf = (OggVorbis_File*) malloc(sizeof(OggVorbis_File));
@@ -457,7 +458,7 @@
int val;
long pos;
- if(!PyArg_ParseTuple(args, "l", &pos))
+ if (!PyArg_ParseTuple(args, "l", &pos))
return NULL;
val = ov_raw_seek(ov_self->ovf, pos);
@@ -472,7 +473,7 @@
int val;
ogg_int64_t pos;
- if(!PyArg_ParseTuple(args, "O", &longobj))
+ if (!PyArg_ParseTuple(args, "O", &longobj))
return NULL;
if (!modinfo->arg_to_int64(longobj, &pos))
@@ -490,7 +491,7 @@
PyObject *longobj;
ogg_int64_t pos;
- if(!PyArg_ParseTuple(args, "O", &longobj))
+ if (!PyArg_ParseTuple(args, "O", &longobj))
return NULL;
if (!modinfo->arg_to_int64(longobj, &pos))
@@ -507,7 +508,7 @@
int val;
double pos;
- if(!PyArg_ParseTuple(args, "d", &pos))
+ if (!PyArg_ParseTuple(args, "d", &pos))
return NULL;
val = ov_time_seek(ov_self->ovf, pos);
@@ -521,7 +522,7 @@
int val;
double pos;
- if(!PyArg_ParseTuple(args, "d", &pos))
+ if (!PyArg_ParseTuple(args, "d", &pos))
return NULL;
val = ov_time_seek_page(ov_self->ovf, pos);
<p><p>1.18 +5 -2 vorbis-python/src/pyvorbisinfo.c
Index: pyvorbisinfo.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/src/pyvorbisinfo.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- pyvorbisinfo.c 31 May 2003 19:41:13 -0000 1.17
+++ pyvorbisinfo.c 9 Sep 2003 03:40:48 -0000 1.18
@@ -843,8 +843,11 @@
vorbis_comment *vcomment;
if (PyArg_ParseTuple(args, "")) {
return py_comment_new_empty();
- } else if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict))
- return NULL;
+ } else {
+ PyErr_Clear(); /* Clear the first error */
+ if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict))
+ return NULL;
+ }
vcomment = create_comment_from_dict(dict);
if (!vcomment)
return NULL;
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list