Cleanup: use PyModule_AddObjectRef where appropriate

This commit is contained in:
Campbell Barton
2024-09-26 17:07:06 +10:00
parent 596067ea35
commit 32c6f9bbd0
45 changed files with 184 additions and 338 deletions

View File

@@ -2679,8 +2679,7 @@ PyObject *BPyInit_bgl()
UNUSED_VARS(LOG);
#endif
PyModule_AddObject(submodule, "Buffer", (PyObject *)&BGL_bufferType);
Py_INCREF((PyObject *)&BGL_bufferType);
PyModule_AddObjectRef(submodule, "Buffer", (PyObject *)&BGL_bufferType);
init_bgl_version_1_0_methods(submodule, dict);
init_bgl_version_1_1_methods(submodule, dict);

View File

@@ -1124,9 +1124,8 @@ PyObject *PyC_DefaultNameSpace(const char *filename)
* In this case an identifier is typically used that is surrounded by angle-brackets.
* It's mainly helpful for the UI and messages to show *something*. */
PyModule_AddObject(mod_main, "__file__", PyC_UnicodeFromBytes(filename));
PyModule_AddObjectRef(mod_main, "__builtins__", builtins);
PyModule_AddObject(mod_main, "__builtins__", builtins);
Py_INCREF(builtins); /* AddObject steals a reference */
return PyModule_GetDict(mod_main);
}