From 81022000063c1fe84d85e8de416d8ab0c2c4c516 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 16 Jan 2019 19:41:29 +0100 Subject: Cleanup/sanitize usages of G.debug_value. There was no documentation at all, some very bad practices (like using G.debug_value > 0 as some sort of global debug print switch), and even an overlapping use of '1' value... Also, python setter did not check for valid range (since this is a short, not an int). --- source/blender/python/intern/bpy_app.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source/blender/python') diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index bba9eee0316..01c8573f589 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -297,7 +297,7 @@ static PyObject *bpy_app_binary_path_python_get(PyObject *self, void *UNUSED(clo } PyDoc_STRVAR(bpy_app_debug_value_doc, -"Int, number which can be set to non-zero values for testing purposes" +"Short, number which can be set to non-zero values for testing purposes" ); static PyObject *bpy_app_debug_value_get(PyObject *UNUSED(self), void *UNUSED(closure)) { @@ -313,7 +313,13 @@ static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void return -1; } - G.debug_value = param; + if (param < SHRT_MIN || param > SHRT_MAX) { + PyErr_SetString(PyExc_ValueError, + "bpy.app.debug_value can only be set to short range [-32768, 32767]"); + return -1; + } + + G.debug_value = (short)param; WM_main_add_notifier(NC_WINDOW, NULL); -- cgit v1.2.3