[Python-checkins] python/dist/src/Modules ossaudiodev.c,1.32,1.33

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Mon, 02 Jun 2003 07:11:48 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv7096

Modified Files:
	ossaudiodev.c 
Log Message:
Fix a subtle decref bug that caused a GC assertion to fail in a debug
build (assert(gc->gc.gc_refs != 0) in visit_decref()).

Because OSSAudioError is a global, we must compensate (twice!) for
PyModule_AddObject()'s "helpful" decref of the object it adds.


Index: ossaudiodev.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/ossaudiodev.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** ossaudiodev.c	29 May 2003 23:44:44 -0000	1.32
--- ossaudiodev.c	2 Jun 2003 14:11:45 -0000	1.33
***************
*** 939,942 ****
--- 939,945 ----
      OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError", NULL, NULL);
      if (OSSAudioError) {
+ 	/* Each call to PyModule_AddObject decrefs it; compensate: */
+ 	Py_INCREF(OSSAudioError);
+ 	Py_INCREF(OSSAudioError);
          PyModule_AddObject(m, "error", OSSAudioError);
          PyModule_AddObject(m, "OSSAudioError", OSSAudioError);