File: _portaudiomodule.c
Function: pa_write_stream
Error: ob_refcnt of new ref from call to Py_BuildValue is 1 too high
2126 static PyObject *
2127 pa_write_stream(PyObject *self, PyObject *args)
2128 {
2129   const char *data;
2130   int total_size;
2131   int total_frames;
2132   int err;
2133   int should_throw_exception = 0;
2134 
2135   PyObject *stream_arg;
2136   _pyAudio_Stream *streamObject;
2137 
2138   if (!PyArg_ParseTuple(args, "O!s#i|i",
when PyArg_ParseTuple() succeeds
taking False path
2139 			&_pyAudio_StreamType,
2140 			&stream_arg,
2141 			&data,
2142 			&total_size,
2143 			&total_frames,
2144 			&should_throw_exception))
2145     return NULL;
2146 
2147   /* make sure total frames is larger than 0 */
2148   if (total_frames < 0) {
when considering range: 0 <= value <= 0x7fffffff
taking False path
2149     PyErr_SetString(PyExc_ValueError,
2150 		    "Invalid number of frames");
2151     return NULL;
2152   }
2153 
2154   streamObject = (_pyAudio_Stream *) stream_arg;
2155 
2156   if (!_is_open(streamObject)) {
when considering range: 1 <= value <= 0x7fffffff
taking False path
2157     PyErr_SetObject(PyExc_IOError,
2158 		    Py_BuildValue("(s,i)",
2159 				  "Stream closed",
2160 				  paBadStreamPtr));
2161     return NULL;
2162   }
2163 
2164   PaStream *stream = streamObject->stream;
2165 
2166   Py_BEGIN_ALLOW_THREADS
releasing the GIL by calling PyEval_SaveThread()
2167   err = Pa_WriteStream(stream, data, total_frames);
2168   Py_END_ALLOW_THREADS
reacquiring the GIL by calling PyEval_RestoreThread()
2169 
2170   if (err != paNoError) {
when considering range: -0x80000000 <= value <= -1
taking True path
2171     if (err == paOutputUnderflowed) {
when considering range: -0x80000000 <= value <= -9981
taking False path
2172       if (should_throw_exception)
2173 	goto error;
2174     } else
2175       goto error;
2176   }
2177 
2178   Py_INCREF(Py_None);
2179   return Py_None;
2180 
2181  error:
2182   /* cleanup */
2183   _cleanup_Stream_object(streamObject);
2184 
2185 #ifdef VERBOSE
2186   fprintf(stderr, "An error occured while using the portaudio stream\n");
2187   fprintf(stderr, "Error number: %d\n", err);
2188   fprintf(stderr, "Error message: %s\n", Pa_GetErrorText(err));
2189 #endif
2190 
2191   PyErr_SetObject(PyExc_IOError,
when Py_BuildValue() succeeds
calling PyErr_SetObject()
new ref from call to Py_BuildValue allocated at:   PyErr_SetObject(PyExc_IOError,
ob_refcnt is now refs: 1 + N where N >= 0
ob_refcnt is now refs: 1 + N where N >= 1
2192 		  Py_BuildValue("(s,i)",
2193 				Pa_GetErrorText(err),
2194 				err));
2195   return NULL;
2196 }
ob_refcnt of new ref from call to Py_BuildValue is 1 too high
was expecting final ob_refcnt to be N + 0 (for some unknown N)
but final ob_refcnt is N + 1
found 9 similar trace(s) to this