- missing return values
authorCampbell Barton <ideasman42@gmail.com>
Wed, 4 Nov 2009 22:36:46 +0000 (22:36 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 4 Nov 2009 22:36:46 +0000 (22:36 +0000)
- more detailed exceptions (always give file:line incase the python exception doesnt)
- fix some errors in the edit docs

editing docs still fails, need to figure out why.

release/scripts/op/wm.py
source/blender/python/intern/bpy_operator_wrap.c
source/blender/python/intern/bpy_util.c
source/blender/windowmanager/intern/wm_operators.c

index a9d62f9b405b04bd84f9f8f9cea2cfb36293587d..1bd5635932ff737a92f1851d85c632569190f222 100644 (file)
@@ -321,7 +321,7 @@ class WM_OT_doc_edit(bpy.types.Operator):
         class_name, class_prop = self.doc_id.split('.')
 
         if not self.doc_new:
-            return 'OPERATOR_CANCELLED'
+            return ('CANCELLED',)
 
         # check if this is an operator
         op_name = class_name.upper() + '_OT_' + class_prop
@@ -334,7 +334,7 @@ class WM_OT_doc_edit(bpy.types.Operator):
             rna = op_class.bl_rna
             doc_orig = rna.description
             if doc_orig == self.doc_new:
-                return 'OPERATOR_CANCELLED'
+                return ('CANCELLED',)
 
             print("op - old:'%s' -> new:'%s'" % (doc_orig, self.doc_new))
             upload["title"] = 'OPERATOR %s:%s' % (self.doc_id, doc_orig)
@@ -346,7 +346,7 @@ class WM_OT_doc_edit(bpy.types.Operator):
             rna = getattr(bpy.types, class_name).bl_rna
             doc_orig = rna.properties[class_prop].description
             if doc_orig == self.doc_new:
-                return 'OPERATOR_CANCELLED'
+                return ('CANCELLED',)
 
             print("rna - old:'%s' -> new:'%s'" % (doc_orig, self.doc_new))
             upload["title"] = 'RNA %s:%s' % s(self.doc_id, doc_orig)
index b0754ee1cde58e03dc65e38ac6105db2b7515a1a..95ffd3e11215f6cbb0da40f00ecdb080039d7601 100644 (file)
@@ -178,8 +178,10 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperatorType *ot, wmOperat
                        
                } else if (BPY_flag_from_seq(pyop_ret_flags, ret, &ret_flag) == -1) {
                        /* the returned value could not be converted into a flag */
-                       if(op)
+                       if(op) {
+                               fprintf(stderr, "error using return value from \"%s\"\n", op->idname); // for some reason the error raised doesnt include file:line... this helps
                                BPy_errors_to_report(op->reports);
+                       }
 
                        ret_flag = OPERATOR_CANCELLED;
                }
index 1766be62c837b6a710464b57884610c37fb8a023..86407e0c8185ec6ab57c6bf25159250ff53b0f57 100644 (file)
@@ -69,7 +69,7 @@ static char *bpy_flag_error_str(BPY_flag_def *flagdef)
                BLI_dynstr_appendf(dynstr, fd!=flagdef?", '%s'":"'%s'", fd->name);
                fd++;
        }
-       
+
        cstring = BLI_dynstr_get_cstring(dynstr);
        BLI_dynstr_free(dynstr);
        return cstring;
@@ -414,7 +414,10 @@ int BPy_errors_to_report(ReportList *reports)
 {
        PyObject *pystring;
        char *cstring;
-       
+
+       char *filename;
+       int lineno;
+
        if (!PyErr_Occurred())
                return 1;
        
@@ -432,10 +435,15 @@ int BPy_errors_to_report(ReportList *reports)
                return 0;
        }
        
+       BPY_getFileAndNum(&filename, &lineno);
+       
        cstring= _PyUnicode_AsString(pystring);
        
-       BKE_report(reports, RPT_ERROR, cstring);
-       fprintf(stderr, "%s\n", cstring); // not exactly needed. just for testing
+       BKE_reportf(reports, RPT_ERROR, "%s\nlocation:%s:%d\n", cstring, filename, lineno);
+       
+       fprintf(stderr, "%s\nlocation:%s:%d\n", cstring, filename, lineno); // not exactly needed. just for testing
+       
        Py_DECREF(pystring);
        return 1;
 }
+
index db09619046e3423d2315c302150e7588e3c55c13..35e02d86b085182544c3fcf8adf256ba4e4b89bd 100644 (file)
@@ -2470,9 +2470,9 @@ static EnumPropertyItem *rna_id_itemf(bContext *C, PointerRNA *ptr, int *free, I
 /* can add more */
 EnumPropertyItem *RNA_group_itemf(bContext *C, PointerRNA *ptr, int *free)
 {
-       rna_id_itemf(C, ptr, free, (ID *)CTX_data_main(C)->group.first);
+       return rna_id_itemf(C, ptr, free, (ID *)CTX_data_main(C)->group.first);
 }
 EnumPropertyItem *RNA_scene_itemf(bContext *C, PointerRNA *ptr, int *free)
 {
-       rna_id_itemf(C, ptr, free, (ID *)CTX_data_main(C)->scene.first);
+       return rna_id_itemf(C, ptr, free, (ID *)CTX_data_main(C)->scene.first);
 }