Commits

Philip Jenvey committed 5ce8d09

fix jit translation, now that elidable is stricter

Comments (0)

Files changed (1)

pypy/module/_rawffi/alt/interp_struct.py

 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.typedef import TypeDef, interp_attrproperty
 from pypy.interpreter.gateway import interp2app, unwrap_spec
-from pypy.interpreter.error import oefmt
+from pypy.interpreter.error import OperationError, oefmt
 from pypy.module._rawffi.alt.interp_ffitype import W_FFIType
 from pypy.module._rawffi.alt.type_converter import FromAppLevelConverter, ToAppLevelConverter
 
         rawmem = rffi.cast(rffi.VOIDP, addr)
         return W__StructInstance(self, allocate=False, autofree=True, rawmem=rawmem)
 
+    def get_type_and_offset_for_field(self, space, w_name):
+        name = space.str_w(w_name)
+        try:
+            return self._get_type_and_offset_for_field(space, name)
+        except KeyError:
+            raise OperationError(space.w_AttributeError, w_name)
+
     @jit.elidable_promote('0')
-    def get_type_and_offset_for_field(self, space, name):
-        try:
-            w_field = self.name2w_field[name]
-        except KeyError:
-            raise oefmt(space.w_AttributeError, '%s', name)
+    def _get_type_and_offset_for_field(self, space, name):
+        w_field = self.name2w_field[name]
         return w_field.w_ffitype, w_field.offset
 
 
         addr = rffi.cast(rffi.ULONG, self.rawmem)
         return space.wrap(addr)
 
-    @unwrap_spec(name=str)
-    def getfield(self, space, name):
+    def getfield(self, space, w_name):
         w_ffitype, offset = self.structdescr.get_type_and_offset_for_field(
-            space, name)
+            space, w_name)
         field_getter = GetFieldConverter(space, self.rawmem, offset)
         return field_getter.do_and_wrap(w_ffitype)
 
-    @unwrap_spec(name=str)
-    def setfield(self, space, name, w_value):
+    def setfield(self, space, w_name, w_value):
         w_ffitype, offset = self.structdescr.get_type_and_offset_for_field(
-            space, name)
+            space, w_name)
         field_setter = SetFieldConverter(space, self.rawmem, offset)
         field_setter.unwrap_and_do(w_ffitype, w_value)