Handle unicode objects in stringfiled by converting via a str() call

This commit is contained in:
Kovid Goyal 2006-11-21 23:28:18 +00:00
parent 50df03806f
commit e3a9bfc265

View File

@ -187,6 +187,7 @@ class stringfield(object):
return obj.unpack(start=self._start, fmt="<"+length+"s")[0] return obj.unpack(start=self._start, fmt="<"+length+"s")[0]
def __set__(self, obj, val): def __set__(self, obj, val):
if val.__class__.__name__ != 'str': val = str(val)
obj.pack(val, start=self._start, fmt="<"+str(len(val))+"s") obj.pack(val, start=self._start, fmt="<"+str(len(val))+"s")
def __repr__(self): def __repr__(self):