def __setvalue__(self, value):
'''Set the _char_t to the str ``value``.'''
if isinstance(value, __builtin__.str):
try: value = __builtin__.unicode(value, 'ascii')
except UnicodeDecodeError: return super(pint.integer_t,self).__setvalue__(str(value))
elif isinstance(value, __builtin__.unicode):
value = value
else:
raise ValueError(self, '_char_t.set', 'User tried to set a value of an incorrect type : {:s}'.format(value.__class__))
res = value.encode(self.encoding.name)
return super(pint.integer_t,self).__setvalue__(res)
评论列表
文章目录