return _create_from_ptr(ptr)
def __setitem__(self, key, value):
- # we can only set numbers and strings
- if not isinstance(value, (numbers.Number, str)):
- raise TypeError('expecting number object or string')
-
- # raises if index is somehow invalid
+ # raises if key is somehow invalid
field = self[key]
- if not isinstance(field, (_NumericField, _StringField)):
- raise TypeError('can only set the value of a number or string field')
-
# the field's property does the appropriate conversion or raises
# the appropriate exception
field.value = value
struct_ft.append_field('A', elem_ft)
struct_field = struct_ft()
- with self.assertRaises(TypeError):
+ # Will fail on access to .items() of the value
+ with self.assertRaises(AttributeError):
struct_field['A'] = 23
def test_setitem_none(self):