if( !val.isValid() ) { if( value->ob_type ) PyErr_Format( PyExc_TypeError, "Unsupported object type: %s", value->ob_type->tp_name ); else PyErr_Format( PyExc_TypeError, "Unknown object type" ); return 0; }
int wpChar_setAttr( wpChar *self, char *name, PyObject *value ){	// Special Python things.	if( !strcmp( "events", name ) )	{		if( !PyList_Check( value ) )		{			PyErr_BadArgument();			return -1;		}		self->pChar->clearEvents();		int i;		for( i = 0; i < PyList_Size( value ); ++i )		{			if( !PyString_Check( PyList_GetItem( value, i ) ) )				continue;			cPythonScript *script = ScriptManager::instance()->find( PyString_AsString( PyList_GetItem( value, i ) ) );			if( script )				self->pChar->addEvent( script );		}	}	else	{		cVariant val;		if( PyString_Check( value ) )			val = cVariant( PyString_AsString( value ) );		else if( PyUnicode_Check( value ) )			val = cVariant(QString::fromUcs2((ushort*)PyUnicode_AsUnicode(value)));		else if( PyInt_Check( value ) )			val = cVariant( PyInt_AsLong( value ) );		else if( checkWpItem( value ) )			val = cVariant( getWpItem( value ) );		else if( checkWpChar( value ) )			val = cVariant( getWpChar( value ) );		else if( checkWpCoord( value ) )			val = cVariant( getWpCoord( value ) );		else if( PyFloat_Check( value ) )			val = cVariant( PyFloat_AsDouble( value ) );		if( !val.isValid() )		{			if( value->ob_type )				PyErr_Format( PyExc_TypeError, "Unsupported object type: %s", value->ob_type->tp_name );			else				PyErr_Format( PyExc_TypeError, "Unknown object type" );			return 0;		}		stError *error = self->pChar->setProperty( name, val );		if( error )		{			PyErr_Format( PyExc_TypeError, "Error while setting attribute '%s': %s", name, error->text.latin1() );			delete error;			return 0;		}	}	return 0;}