diff options
author | Ken Hughes <khughes@pacific.edu> | 2006-12-21 19:05:01 +0300 |
---|---|---|
committer | Ken Hughes <khughes@pacific.edu> | 2006-12-21 19:05:01 +0300 |
commit | 7679634ff8ec89a7896479c4424a634d1dd3aeb3 (patch) | |
tree | af5aa520ce40a07355607251f8acdafa836dc9ca /source/blender/python/api2_2x/Scene.c | |
parent | af60771ecad15c36ac99f7883cf0656b3d74cd4e (diff) |
Python API
----------
Bugfix: Scene.objects.new() didn't check string inputs correctly.
Diffstat (limited to 'source/blender/python/api2_2x/Scene.c')
-rw-r--r-- | source/blender/python/api2_2x/Scene.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c index 9b3a1fff9e6..4970ca2078d 100644 --- a/source/blender/python/api2_2x/Scene.c +++ b/source/blender/python/api2_2x/Scene.c @@ -1323,7 +1323,7 @@ static PyObject *SceneObSeq_new( BPy_SceneObSeq * self, PyObject *args ) if (self->mode != 0) return EXPP_ReturnPyObjError( PyExc_TypeError, "Cannot add new to objects.selection or objects.context!" ); - + if( !PyArg_ParseTuple( args, "O|s", &py_data, &name ) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected an object and optionally a string as arguments" ); @@ -1354,13 +1354,17 @@ static PyObject *SceneObSeq_new( BPy_SceneObSeq * self, PyObject *args ) } else if( Text3d_CheckPyObject( py_data ) ) { data = ( void * ) Text3d_FromPyObject( py_data ); type = OB_FONT; - } else if( desc = PyString_FromString( (PyObject *)py_data ) ) { - if( !strcmp( desc, "Empty" ) ) + } else if( ( desc = PyString_AsString( (PyObject *)py_data ) ) != NULL ) { + if( !strcmp( desc, "Empty" ) ) { type = OB_EMPTY; - data = NULL; - } else + data = NULL; + } else + goto typeError; + } else { +typeError: return EXPP_ReturnPyObjError( PyExc_TypeError, "expected an object and optionally a string as arguments" ); + } if (!name) { if (type == OB_EMPTY) @@ -1451,6 +1455,7 @@ static PyObject *SceneObSeq_new( BPy_SceneObSeq * self, PyObject *args ) test_object_materials( (ID *)object->data ); return Object_CreatePyObject( object ); + } |