Skip to content

Commit 681281b

Browse files
committed
check for input integer
1 parent ed5bec4 commit 681281b

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/gstype_python.i

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,3 +2436,16 @@ static bool getRowFields(GSRow* row, int columnCount, GSType* typeList, bool tim
24362436
}
24372437
return $result;
24382438
}
2439+
2440+
//Correct check for input integer: when input invalid value (boolean), should throw exception
2441+
%typemap(in) (int32_t) {
2442+
if (PyBool_Check($input)) {
2443+
PyErr_SetString(PyExc_ValueError, "Invalid value for int32_t value");
2444+
SWIG_fail;
2445+
}
2446+
int checkConvert = SWIG_AsVal_int($input, &$1);
2447+
if (!SWIG_IsOK(checkConvert)) {
2448+
PyErr_SetString(PyExc_ValueError, "Invalid value for int32_t value");
2449+
SWIG_fail;
2450+
}
2451+
}

0 commit comments

Comments
 (0)