Esempio n. 1
0
 def convert_from_object(self, cdata, w_ob):
     if self.value_fits_long:
         value = misc.as_long(self.space, w_ob)
         if self.value_smaller_than_long:
             if value != misc.signext(value, self.size):
                 self._overflow(w_ob)
         misc.write_raw_signed_data(cdata, value, self.size)
     else:
         self._convert_from_object_longlong(cdata, w_ob)
Esempio n. 2
0
 def convert_from_object(self, cdata, w_ob):
     if self.value_fits_long:
         value = misc.as_long(self.space, w_ob)
         if self.value_smaller_than_long:
             size = self.size
             if size == 1:
                 signextended = misc.signext(value, 1)
             elif size == 2:
                 signextended = misc.signext(value, 2)
             elif size == 4:
                 signextended = misc.signext(value, 4)
             else:
                 raise AssertionError("unsupported size")
             if value != signextended:
                 self._overflow(w_ob)
         misc.write_raw_signed_data(cdata, value, self.size)
     else:
         self._convert_from_object_longlong(cdata, w_ob)
Esempio n. 3
0
 def convert_from_object(self, cdata, w_ob):
     if self.value_fits_long:
         value = misc.as_long(self.space, w_ob)
         if self.value_smaller_than_long:
             if value != misc.signext(value, self.size):
                 self._overflow(w_ob)
         misc.write_raw_signed_data(cdata, value, self.size)
     else:
         self._convert_from_object_longlong(cdata, w_ob)