Skip to content

Commit 0078d9f

Browse files
committed
pytrap: add object type check into parameter parsing
1 parent c274d58 commit 0078d9f

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

pytrap/src/unirecmodule.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,21 +1769,12 @@ UnirecTemplate_getDict(pytrap_unirectemplate *self)
17691769
static PyObject *
17701770
UnirecTemplate_getFieldType(pytrap_unirectemplate *self, PyObject *args)
17711771
{
1772-
PyObject *name;
1772+
PyObject *name, *result = NULL;
17731773

1774-
if (!PyArg_ParseTuple(args, "O", &name)) {
1774+
if (!PyArg_ParseTuple(args, "O!", &PyUnicode_Type, &name)) {
17751775
return NULL;
17761776
}
17771777

1778-
#if PY_MAJOR_VERSION >= 3
1779-
if (!PyUnicode_Check(name))
1780-
#else
1781-
if (!PyUnicode_Check(name) && !PyString_Check(name))
1782-
#endif
1783-
{
1784-
PyErr_SetString(PyExc_TypeError, "Argument field_name must be string.");
1785-
return NULL;
1786-
}
17871778
int32_t field_id = UnirecTemplate_get_field_id(self, name);
17881779

17891780
switch (ur_get_type(field_id)) {

0 commit comments

Comments
 (0)