From d3794d9f945d3d85394549e4570c38147a3283a1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 18 Nov 2009 13:02:09 +0000 Subject: [PATCH] fix for memory leak, use Key Errors for pyrna getitem access & idprops --- source/blender/makesrna/intern/rna_access.c | 7 +------ source/blender/python/generic/IDProp.c | 4 ++-- source/blender/python/intern/bpy_rna.c | 4 ++-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 355b61a0c49..3e30827fad2 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2344,13 +2344,8 @@ int RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prope if(use_id_prop) { /* look up property name in current struct */ IDProperty *group= RNA_struct_idproperties(ptr, 0); - if(!group) - return 0; - - if(rna_token_strip_quotes(token)) + if(group && rna_token_strip_quotes(token)) prop= (PropertyRNA *)IDP_GetPropertyFromGroup(group, token+1); - else - prop= NULL; } else { prop= RNA_struct_find_property(&curptr, token); diff --git a/source/blender/python/generic/IDProp.c b/source/blender/python/generic/IDProp.c index 6d71332b9ec..2339350823d 100644 --- a/source/blender/python/generic/IDProp.c +++ b/source/blender/python/generic/IDProp.c @@ -322,7 +322,7 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val) MEM_freeN(pkey); return 0; } else { - PyErr_SetString( PyExc_RuntimeError, "property not found in group" ); + PyErr_SetString( PyExc_KeyError, "property not found in group" ); return -1; } } @@ -336,7 +336,7 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val) err = BPy_IDProperty_Map_ValidateAndCreate(_PyUnicode_AsString(key), prop, val); if (err) { - PyErr_SetString( PyExc_RuntimeError, err ); + PyErr_SetString( PyExc_KeyError, err ); return -1; } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 024473f596a..ba268201b81 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1218,14 +1218,14 @@ static PyObject *pyrna_struct_subscript( BPy_StructRNA *self, PyObject *key ) group= RNA_struct_idproperties(&self->ptr, 0); if(group==NULL) { - PyErr_Format( PyExc_TypeError, "key \"%s\" not found", name); + PyErr_Format( PyExc_KeyError, "key \"%s\" not found", name); return NULL; } idprop= IDP_GetPropertyFromGroup(group, name); if(idprop==NULL) { - PyErr_Format( PyExc_TypeError, "key \"%s\" not found", name); + PyErr_Format( PyExc_KeyError, "key \"%s\" not found", name); return NULL; }