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.
This commit is contained in:
Guido van Rossum 2003-06-02 14:11:45 +00:00
parent 01e3273164
commit f39dafb10a
1 changed files with 3 additions and 0 deletions

View File

@ -938,6 +938,9 @@ initossaudiodev(void)
OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError", NULL, NULL); OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError", NULL, NULL);
if (OSSAudioError) { if (OSSAudioError) {
/* Each call to PyModule_AddObject decrefs it; compensate: */
Py_INCREF(OSSAudioError);
Py_INCREF(OSSAudioError);
PyModule_AddObject(m, "error", OSSAudioError); PyModule_AddObject(m, "error", OSSAudioError);
PyModule_AddObject(m, "OSSAudioError", OSSAudioError); PyModule_AddObject(m, "OSSAudioError", OSSAudioError);
} }