Revision: 39700
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39700
Author:   campbellbarton
Date:     2011-08-25 17:54:30 +0000 (Thu, 25 Aug 2011)
Log Message:
-----------
error when a python operator gave an incorrect return value was near useless, 
re-raise a more comprehensive error which includes the operator name.

Modified Paths:
--------------
    trunk/blender/source/blender/python/intern/bpy_operator.c
    trunk/blender/source/blender/python/intern/bpy_rna.c

Modified: trunk/blender/source/blender/python/intern/bpy_operator.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_operator.c   2011-08-25 
17:12:53 UTC (rev 39699)
+++ trunk/blender/source/blender/python/intern/bpy_operator.c   2011-08-25 
17:54:30 UTC (rev 39700)
@@ -293,7 +293,7 @@
         * function corrects bpy.data (internal Main pointer) */
        BPY_modules_update(C);
 
-       /* needed for when WM_OT_read_factory_settings us called fro within a 
script */
+       /* needed for when WM_OT_read_factory_settings us called from within a 
script */
        bpy_import_main_set(CTX_data_main(C));
 
        /* return operator_ret as a bpy enum */

Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c        2011-08-25 
17:12:53 UTC (rev 39699)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c        2011-08-25 
17:54:30 UTC (rev 39700)
@@ -6417,7 +6417,21 @@
                        err= -1;
                }
                else if(ret_len==1) {
-                       err= pyrna_py_to_prop(&funcptr, pret_single, 
retdata_single, ret, "calling class function:");
+                       err= pyrna_py_to_prop(&funcptr, pret_single, 
retdata_single, ret, "");
+
+                       /* when calling operator funcs only gives 
Function.result with
+                        * no line number since the func has finished calling 
on error,
+                        * re-raise the exception with more info since it would 
be slow to
+                        * create prefix on every call (when there are no 
errors) */
+                       if(err == -1 && PyErr_Occurred()) {
+                               PyObject *error_type, *error_value, 
*error_traceback;
+                               PyErr_Fetch(&error_type, &error_value, 
&error_traceback);
+
+                               PyErr_Format(error_type,
+                                            "expected class %.200s, function 
%.200s: incompatible return value%S",
+                                            RNA_struct_identifier(ptr->type), 
RNA_function_identifier(func),
+                                            error_value);
+                       }
                }
                else if (ret_len > 1) {
 

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to