Add conversion checking on the value of a seq column
This commit is contained in:
@ -94,10 +94,16 @@ cdef class OBIDMS_column_multi_elts_seq(OBIDMS_column_multi_elts):
|
|||||||
|
|
||||||
cpdef set_item(self, index_t line_nb, str element_name, object value):
|
cpdef set_item(self, index_t line_nb, str element_name, object value):
|
||||||
cdef bytes value_b
|
cdef bytes value_b
|
||||||
|
|
||||||
if value is None :
|
if value is None :
|
||||||
value_b = OBISeq_NA
|
value_b = OBISeq_NA
|
||||||
else :
|
elif isinstance(value, bytes) :
|
||||||
|
value_b = value
|
||||||
|
elif isinstance(value, str) :
|
||||||
value_b = str2bytes(value)
|
value_b = str2bytes(value)
|
||||||
|
else:
|
||||||
|
raise TypeError('Sequence value must be of type Bytes, Str or None')
|
||||||
|
|
||||||
if obi_column_set_obiseq_with_elt_name_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name), value_b) < 0:
|
if obi_column_set_obiseq_with_elt_name_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name), value_b) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user