[gnumeric] PythonLoader: use more modern python ref handling.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] PythonLoader: use more modern python ref handling.
- Date: Mon, 22 Mar 2021 02:02:40 +0000 (UTC)
commit 21464b296d9244360e7f5aa7c66bf1af7dca171f
Author: Morten Welinder <terra gnome org>
Date: Sun Mar 21 22:02:20 2021 -0400
PythonLoader: use more modern python ref handling.
plugins/python-loader/gnm-py-interpreter.c | 9 ++-------
plugins/python-loader/py-gnumeric.c | 3 +--
plugins/python-loader/python-loader.c | 8 +++-----
3 files changed, 6 insertions(+), 14 deletions(-)
---
diff --git a/plugins/python-loader/gnm-py-interpreter.c b/plugins/python-loader/gnm-py-interpreter.c
index ccc3d9e86..b921bd0a3 100644
--- a/plugins/python-loader/gnm-py-interpreter.c
+++ b/plugins/python-loader/gnm-py-interpreter.c
@@ -60,10 +60,7 @@ gnm_py_interpreter_finalize (GObject *obj)
{
GnmPyInterpreter *interpreter = GNM_PY_INTERPRETER (obj);
- if (interpreter->stringio_class != NULL) {
- Py_DECREF (interpreter->stringio_class);
- }
-
+ Py_CLEAR (interpreter->stringio_class);
parent_class->finalize (obj);
}
@@ -161,9 +158,7 @@ run_print_string (const char *cmd, PyObject *stdout_obj)
if (PyFile_WriteObject (v, stdout_obj, Py_PRINT_RAW) != 0)
PyErr_Clear ();
}
- if (v) {
- Py_DECREF (v);
- }
+ Py_XDECREF (v);
}
void
diff --git a/plugins/python-loader/py-gnumeric.c b/plugins/python-loader/py-gnumeric.c
index e0892d3df..af4b5fc7d 100644
--- a/plugins/python-loader/py-gnumeric.c
+++ b/plugins/python-loader/py-gnumeric.c
@@ -852,8 +852,7 @@ py_gnumeric_shutdown (void)
if (GnmModule) {
// At least clear the module. We leak a ref somewhere.
PyDict_Clear (PyModule_GetDict (GnmModule));
- Py_DECREF (GnmModule);
- GnmModule = NULL;
+ Py_CLEAR (GnmModule);
}
}
diff --git a/plugins/python-loader/python-loader.c b/plugins/python-loader/python-loader.c
index 1ca96287f..10fc3512c 100644
--- a/plugins/python-loader/python-loader.c
+++ b/plugins/python-loader/python-loader.c
@@ -242,8 +242,8 @@ gplp_func_file_probe (G_GNUC_UNUSED GOFileOpener const *fo, GOPluginService *ser
probe_result = PyObject_CallFunction
(loader_data->python_func_file_probe,
"O", input_wrapper);
- Py_DECREF (input_wrapper);
}
+ Py_XDECREF (input_wrapper);
if (probe_result != NULL) {
result = PyObject_IsTrue (probe_result);
Py_DECREF (probe_result);
@@ -335,8 +335,7 @@ gplp_load_service_file_opener (GOPluginLoader *loader,
loader_data = g_new (ServiceLoaderDataFileOpener, 1);
loader_data->python_func_file_probe = python_func_file_probe;
loader_data->python_func_file_open = python_func_file_open;
- if (python_func_file_probe != NULL)
- Py_INCREF (loader_data->python_func_file_probe);
+ Py_XINCREF (loader_data->python_func_file_probe);
Py_INCREF (loader_data->python_func_file_open);
g_object_set_data_full
(G_OBJECT (service), "loader_data", loader_data,
@@ -787,8 +786,7 @@ gplp_unload_service_function_group (GOPluginLoader *loader,
GO_INIT_RET_ERROR_INFO (ret_error);
loader_data = g_object_get_data (G_OBJECT (service), "loader_data");
SWITCH_TO_PLUGIN (go_plugin_service_get_plugin (service));
- Py_DECREF (loader_data->python_fn_info_dict);
- loader_data->python_fn_info_dict = NULL;
+ Py_CLEAR (loader_data->python_fn_info_dict);
}
typedef struct {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]