File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 22Example module with C-level module-global state, and
33
44- a simple function that updates and queries the state
5- - a class wihose repr() queries the same module state (for an example of
5+ - a class wihose repr() queries the same module state (as an example of
66 PyType_GetModuleByToken)
77
88Once compiled and renamed to not include a version tag (for example
@@ -67,6 +67,7 @@ exampletype_repr(PyObject *self)
6767 return NULL ;
6868 }
6969 examplemodule_state * state = PyModule_GetState (module );
70+ Py_DECREF (module );
7071 if (!state ) {
7172 return NULL ;
7273 }
@@ -95,8 +96,10 @@ examplemodule_exec(PyObject *module) {
9596 return -1 ;
9697 }
9798 if (PyModule_AddType (module , type ) < 0 ) {
99+ Py_DECREF (type );
98100 return -1 ;
99101 }
102+ Py_DECREF (type );
100103 return 0 ;
101104}
102105
You can’t perform that action at this time.
0 commit comments