def __init__(self, **attrs):
res = super(string,self).__init__(**attrs)
# ensure that self._object_ is using a fixed-width encoding
_object_ = self._object_
# encode 3 types of strings and ensure that their lengths scale up with their string sizes
res,single,double = ( __builtin__.unicode(n, 'ascii').encode(_object_.encoding.name) for n in ('\x00', 'A', 'AA') )
if len(res) * 2 == len(single) * 2 == len(double):
return
raise ValueError(self.classname(), 'string.__init__', 'User tried to specify a variable-width character encoding : {:s}'.format(_object_.encoding.name))
评论列表
文章目录