renamed bpy.sys to bpy.utils, since it used to be a attempt to replace pythons sys...
[blender.git] / source / blender / python / intern / bpy_interface.c
index dc7f6947f38025448aafcef19f0339cb856d0e8c..b465a494a4d88013d9b7e641420e1998bc8c5186 100644 (file)
@@ -200,7 +200,7 @@ static void bpy_init_modules( void )
                }
                
                bpy_import_test("bpy_ops"); /* adds its self to bpy.ops */
-               bpy_import_test("bpy_sys"); /* adds its self to bpy.sys */
+               bpy_import_test("bpy_utils"); /* adds its self to bpy.sys */
                bpy_import_test("bpy_ext"); /* extensions to our existing types */
        }
        
@@ -971,28 +971,36 @@ int bpy_context_get(bContext *C, const char *member, bContextDataResult *result)
                CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data);
                done= 1;
        }
-       else if (PyList_Check(item)) {
-               int len= PyList_Size(item);
-               int i;
-               for(i = 0; i < len; i++) {
-                       PyObject *list_item = PyList_GET_ITEM(item, i); // XXX check type
-
-                       if(BPy_StructRNA_Check(list_item)) {
-                               /*
-                               CollectionPointerLink *link= MEM_callocN(sizeof(CollectionPointerLink), "bpy_context_get");
-                               link->ptr= ((BPy_StructRNA *)item)->ptr;
-                               BLI_addtail(&result->list, link);
-                               */
-                               ptr= &(((BPy_StructRNA *)list_item)->ptr);
-                               CTX_data_list_add(result, ptr->id.data, ptr->type, ptr->data);
-                       }
-                       else {
-                               printf("List item not a valid type\n");
+       else if (PySequence_Check(item)) {
+               PyObject *seq_fast= PySequence_Fast(item, "bpy_context_get sequence conversion");
+               if (seq_fast==NULL) {
+                       PyErr_Print();
+                       PyErr_Clear();
+               }
+               else {
+                       int len= PySequence_Fast_GET_SIZE(seq_fast);
+                       int i;
+                       for(i = 0; i < len; i++) {
+                               PyObject *list_item= PySequence_Fast_GET_ITEM(seq_fast, i);
+
+                               if(BPy_StructRNA_Check(list_item)) {
+                                       /*
+                                       CollectionPointerLink *link= MEM_callocN(sizeof(CollectionPointerLink), "bpy_context_get");
+                                       link->ptr= ((BPy_StructRNA *)item)->ptr;
+                                       BLI_addtail(&result->list, link);
+                                       */
+                                       ptr= &(((BPy_StructRNA *)list_item)->ptr);
+                                       CTX_data_list_add(result, ptr->id.data, ptr->type, ptr->data);
+                               }
+                               else {
+                                       printf("List item not a valid type\n");
+                               }
+
                        }
+                       Py_DECREF(seq_fast);
 
+                       done= 1;
                }
-
-               done= 1;
        }
 
        if(done==0) {