diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-17 15:21:41 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-17 15:21:41 +0300 |
commit | 51f2dcd08ccde78223449383b98b9f7e35062b24 (patch) | |
tree | d321846ee9e0d09d87dd9e43cc2a6b5f9edaeada /source | |
parent | 7f8a24b614450a05a4b1df80080a19001a851873 (diff) |
- access console languages as modules rather then having the py operator call an operator
- workaround for __getattr__ existing for types that dont support it
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesrna/intern/rna_main.c | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 1b93f6d1056..a068dc7cb26 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -258,7 +258,7 @@ void RNA_def_main(BlenderRNA *brna) {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks."}, {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks."}, {"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks."}, - {"keys", "Key", "rna_Main_key_begin", "Keys", "Key datablocks."}, +/* {"keys", "Key", "rna_Main_key_begin", "Keys", "Key datablocks."}, */ {"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks (DEPRECATED)."}, {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks."}, {"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound datablocks."}, diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index ddc8af117a6..e247b060088 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1205,6 +1205,11 @@ static PyObject *pyrna_struct_subscript( BPy_StructRNA *self, PyObject *key ) IDProperty *group, *idprop; char *name= _PyUnicode_AsString(key); + if(RNA_struct_idproperties_check(&self->ptr)==0) { + PyErr_SetString( PyExc_TypeError, "this type doesn't support IDProperties"); + return NULL; + } + if(name==NULL) { PyErr_SetString( PyExc_TypeError, "only strings are allowed as keys of ID properties"); return NULL; @@ -1512,7 +1517,14 @@ static PyObject *pyrna_struct_getattro( BPy_StructRNA *self, PyObject *pyname ) FunctionRNA *func; if(name[0]=='_') { // rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups - ret = PyObject_GenericGetAttr((PyObject *)self, pyname); + /* annoying exception, maybe we need to have different types for this... */ + if((strcmp(name, "__getitem__")==0 || strcmp(name, "__setitem__")==0) && !RNA_struct_idproperties_check(&self->ptr)) { + PyErr_SetString(PyExc_AttributeError, "StructRNA - no __getitem__ support for this type"); + ret = NULL; + } + else { + ret = PyObject_GenericGetAttr((PyObject *)self, pyname); + } } else if ((prop = RNA_struct_find_property(&self->ptr, name))) { ret = pyrna_prop_to_py(&self->ptr, prop); |