Skip to content

Commit 3f51166

Browse files
committed
fixup! pytrap: add capability to set arrays from dict
1 parent 8cad7b9 commit 3f51166

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pytrap/src/unirecmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ UnirecTemplate_setFromDict(pytrap_unirectemplate *self, PyObject *dict, int skip
15231523
Py_DECREF(idkey);
15241524
return NULL;
15251525
}
1526-
} else if (PyLong_Check(v) || PySequence_Check(v)) {
1526+
} else {
15271527
if (UnirecTemplate_set_local(self, self->data, id, v) == NULL) {
15281528
Py_DECREF(idkey);
15291529
return NULL;

pytrap/test/unirectemplate_unittest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,10 +842,12 @@ def runTest(self):
842842
class ArrayFromDict(unittest.TestCase):
843843
def runTest(self):
844844
import pytrap
845-
rec = pytrap.UnirecTemplate("int8* PPI_PKT_DIRECTIONS,uint8* PPI_PKT_FLAGS,uint16* PPI_PKT_LENGTHS,uint32* DBI_BRST_BYTES,time* DBI_BRST_TIME_START")
845+
rec = pytrap.UnirecTemplate("int8* PPI_PKT_DIRECTIONS,uint8* PPI_PKT_FLAGS,uint16* PPI_PKT_LENGTHS,uint32* DBI_BRST_BYTES,time* DBI_BRST_TIME_START,ipaddr SRC_IP,time TIME")
846846
rec.createMessage(10000)
847847
# prepare dict
848848
data = {
849+
"SRC_IP": pytrap.UnirecIPAddr("10.0.0.1"),
850+
"TIME": pytrap.UnirecTime(1669885132, 853),
849851
"PPI_PKT_DIRECTIONS": [
850852
1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
851853
-1, -1, -1, -1, -1, -1, -1, 1, -1, -1

0 commit comments

Comments
 (0)