diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.c
index 1466d6743843c67e844f3bd9c0fc2dcf5f56f38b..f36a89a96e43074aed973b46d069a5c9f46bfb67 100644
--- a/source/blender/python/intern/bpy_traceback.c
+++ b/source/blender/python/intern/bpy_traceback.c
@@ -216,12 +216,12 @@ bool python_script_error_jump(
   else {
     PyErr_NormalizeException(&exception, &value, (PyObject **)&tb);
 
-    for (tb = (PyTracebackObject *)PySys_GetObject("last_traceback");
-         tb && (PyObject *)tb != Py_None;
-         tb = tb->tb_next)
+    for (PyTracebackObject *tb_iter = (PyTracebackObject *)PySys_GetObject("last_traceback");
+         tb_iter && (PyObject *)tb_iter != Py_None;
+         tb_iter = tb_iter->tb_next)
     {
       PyObject *coerce;
-      const char *tb_filepath = traceback_filepath(tb, &coerce);
+      const char *tb_filepath = traceback_filepath(tb_iter, &coerce);
       const int match = ((BLI_path_cmp(tb_filepath, filepath) == 0) ||
                          (ELEM(tb_filepath[0], '\\', '/') &&
                           BLI_path_cmp(tb_filepath + 1, filepath) == 0));
@@ -229,7 +229,7 @@ bool python_script_error_jump(
 
       if (match) {
         success = true;
-        *r_lineno = *r_lineno_end = tb->tb_lineno;
+        *r_lineno = *r_lineno_end = tb_iter->tb_lineno;
         /* used to break here, but better find the inner most line */
       }
     }