reference count never decrease to zero Py_DECREF

When I run the following code, the while circulation never stops. Why?

Will the PyObject pointer change to Null when the reference number is zero?

#include <sched.h>
#include <Python.h>
int main() {
    Py_Initialize(); 
    PyObject *pModule;
    int time=0;
    pModule = PyImport_ImportModule("entry"); 
    while(pModule!=NULL)
    {
        Py_DECREF(pModule);
        time++;
        printf("this is  decref pmodule, times= %d",time);
    }
    Py_Finalize();  
    return 0;
}


Source: python

Leave a Reply