PyAPI: Make use of PyC_LongAs... API
Avoids setting exceptions inline, also use Matrix_ParseAny for bmesh.ops. Some inline exceptions are kept because they show useful details.
This commit is contained in:
		@@ -1643,7 +1643,7 @@ static int pyrna_py_to_prop(
 | 
			
		||||
					param = PyObject_IsTrue(value);
 | 
			
		||||
				}
 | 
			
		||||
				else {
 | 
			
		||||
					param = PyLong_AsLong(value);
 | 
			
		||||
					param = PyC_Long_AsI32(value);
 | 
			
		||||
 | 
			
		||||
					if (UNLIKELY(param & ~1)) {  /* only accept 0/1 */
 | 
			
		||||
						param = -1;              /* error out below */
 | 
			
		||||
@@ -2079,10 +2079,10 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
 | 
			
		||||
		switch (RNA_property_type(prop)) {
 | 
			
		||||
			case PROP_BOOLEAN:
 | 
			
		||||
			{
 | 
			
		||||
				int param = PyLong_AsLong(value);
 | 
			
		||||
				int param = PyC_Long_AsBool(value);
 | 
			
		||||
 | 
			
		||||
				if (param < 0 || param > 1) {
 | 
			
		||||
					PyErr_SetString(PyExc_TypeError, "expected True/False or 0/1");
 | 
			
		||||
				if (param == -1) {
 | 
			
		||||
					/* error is set */
 | 
			
		||||
					ret = -1;
 | 
			
		||||
				}
 | 
			
		||||
				else {
 | 
			
		||||
@@ -2092,7 +2092,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
 | 
			
		||||
			}
 | 
			
		||||
			case PROP_INT:
 | 
			
		||||
			{
 | 
			
		||||
				int param = PyLong_AsLong(value);
 | 
			
		||||
				int param = PyC_Long_AsI32(value);
 | 
			
		||||
				if (param == -1 && PyErr_Occurred()) {
 | 
			
		||||
					PyErr_SetString(PyExc_TypeError, "expected an int type");
 | 
			
		||||
					ret = -1;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user