[xiph-cvs] cvs commit: ogg-python2/src pyoggsyncstate.c
Arc
arc at xiph.org
Sat Dec 6 08:39:49 PST 2003
arc 03/12/06 11:39:49
Modified: src pyoggsyncstate.c
Log:
.read() will now return an empty buffer (vs fail) when 0 bytes read
Should it instead return an IOError, to match behavior of file objects?
Revision Changes Path
1.4 +3 -0 ogg-python2/src/pyoggsyncstate.c
Index: pyoggsyncstate.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-python2/src/pyoggsyncstate.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- pyoggsyncstate.c 30 Nov 2003 06:33:11 -0000 1.3
+++ pyoggsyncstate.c 6 Dec 2003 16:39:48 -0000 1.4
@@ -139,14 +139,17 @@
&ogg_buffer);
if ( got_bytes < ask_bytes ) ask_bytes = got_bytes;
+
pybufferobj = PyBuffer_New(ask_bytes);
PyObject_AsWriteBuffer(pybufferobj, (void **) &pybuffer, &got_bytes);
if ( got_bytes < ask_bytes ) ask_bytes = got_bytes;
+ if ( got_bytes == 0 ) return pybufferobj; /* If 0, return it now */
memcpy(pybuffer, ogg_buffer, ask_bytes);
ret = ogg_sync_read(PyOggSyncState_AsOggSyncState(self), ask_bytes);
if (ret == OGG_SUCCESS) return pybufferobj;
+ Py_DECREF(pybufferobj);
PyErr_SetString(PyOggError, "Unknown return from ogg_sync_read.");
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