Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-03-28 09:11:34 +0300
committerCampbell Barton <campbell@blender.org>2022-03-28 09:15:41 +0300
commit387b34f0c2b768fcf1972575930e9ae822b7aca6 (patch)
tree5fc5c26d991072c1e6c62a010642c0042c350fd7 /source
parent1466f480c4ea894c2f0b23663fcdba644cceb3f8 (diff)
Cleanup: return success from python_script_error_jump
Relying on checks for the assignment of return arguments isn't so clear especially when there are multiple return arguments.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/intern/bpy_interface_run.c3
-rw-r--r--source/blender/python/intern/bpy_traceback.c16
-rw-r--r--source/blender/python/intern/bpy_traceback.h2
3 files changed, 9 insertions, 12 deletions
diff --git a/source/blender/python/intern/bpy_interface_run.c b/source/blender/python/intern/bpy_interface_run.c
index 8f7437ac1da..9299bd196e2 100644
--- a/source/blender/python/intern/bpy_interface_run.c
+++ b/source/blender/python/intern/bpy_interface_run.c
@@ -39,8 +39,7 @@ static void python_script_error_jump_text(Text *text, const char *filepath)
{
int lineno, lineno_end;
int offset, offset_end;
- python_script_error_jump(filepath, &lineno, &offset, &lineno_end, &offset_end);
- if (lineno != -1) {
+ if (python_script_error_jump(filepath, &lineno, &offset, &lineno_end, &offset_end)) {
/* Start at the end so cursor motion that looses the selection,
* leaves the cursor from the most useful place.
* Also, the end can't always be set, so don't give it priority. */
diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.c
index 6813496be83..40478f3613c 100644
--- a/source/blender/python/intern/bpy_traceback.c
+++ b/source/blender/python/intern/bpy_traceback.c
@@ -162,9 +162,10 @@ finally:
}
/* end copied function! */
-void python_script_error_jump(
+bool python_script_error_jump(
const char *filepath, int *r_lineno, int *r_offset, int *r_lineno_end, int *r_offset_end)
{
+ bool success = false;
PyObject *exception, *value;
PyTracebackObject *tb;
@@ -176,7 +177,7 @@ void python_script_error_jump(
PyErr_Fetch(&exception, &value, (PyObject **)&tb);
if (exception == NULL) {
- return;
+ return false;
}
if (PyErr_GivenExceptionMatches(exception, PyExc_SyntaxError)) {
@@ -200,14 +201,8 @@ void python_script_error_jump(
/* python adds a '/', prefix, so check for both */
if ((BLI_path_cmp(filepath_exc, filepath) == 0) ||
(ELEM(filepath_exc[0], '\\', '/') && BLI_path_cmp(filepath_exc + 1, filepath) == 0)) {
- /* good */
+ success = true;
}
- else {
- *r_lineno = -1;
- }
- }
- else {
- *r_lineno = -1;
}
}
PyErr_Restore(exception, value, (PyObject *)tb); /* takes away reference! */
@@ -228,9 +223,12 @@ void python_script_error_jump(
Py_DECREF(coerce);
if (match) {
+ success = true;
*r_lineno = *r_lineno_end = tb->tb_lineno;
/* used to break here, but better find the inner most line */
}
}
}
+
+ return success;
}
diff --git a/source/blender/python/intern/bpy_traceback.h b/source/blender/python/intern/bpy_traceback.h
index 2ebdab527e8..f5232eca864 100644
--- a/source/blender/python/intern/bpy_traceback.h
+++ b/source/blender/python/intern/bpy_traceback.h
@@ -10,7 +10,7 @@
extern "C" {
#endif
-void python_script_error_jump(
+bool python_script_error_jump(
const char *filepath, int *r_lineno, int *r_offset, int *r_lineno_end, int *r_offset_end);
#ifdef __cplusplus