Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r75269:48cd201a34bf Date: 2015-01-09 11:10 +0100 http://bitbucket.org/pypy/pypy/changeset/48cd201a34bf/
Log: Move the cif_descr back as a class default. This is actually important because of an instantiate() which doesn't call the regular constructor. diff --git a/pypy/module/_cffi_backend/ctypefunc.py b/pypy/module/_cffi_backend/ctypefunc.py --- a/pypy/module/_cffi_backend/ctypefunc.py +++ b/pypy/module/_cffi_backend/ctypefunc.py @@ -27,6 +27,8 @@ _immutable_fields_ = ['fargs[*]', 'ellipsis', 'cif_descr'] kind = "function" + cif_descr = lltype.nullptr(CIF_DESCRIPTION) + def __init__(self, space, fargs, fresult, ellipsis): extra = self._compute_extra_text(fargs, fresult, ellipsis) size = rffi.sizeof(rffi.VOIDP) @@ -34,7 +36,6 @@ could_cast_anything=False) self.fargs = fargs self.ellipsis = bool(ellipsis) - self.cif_descr = lltype.nullptr(CIF_DESCRIPTION) # fresult is stored in self.ctitem if not ellipsis: @@ -50,6 +51,9 @@ raise # else, eat the NotImplementedError. We will get the # exception if we see an actual call + if self.cif_descr: # should not be True, but you never know + lltype.free(self.cif_descr, flavor='raw') + self.cif_descr = lltype.nullptr(CIF_DESCRIPTION) def new_ctypefunc_completing_argtypes(self, args_w): space = self.space @@ -65,10 +69,12 @@ "argument %d passed in the variadic part needs to " "be a cdata object (got %T)", i + 1, w_obj) fvarargs[i] = ct + # xxx call instantiate() directly. It's a bit of a hack. ctypefunc = instantiate(W_CTypeFunc) ctypefunc.space = space ctypefunc.fargs = fvarargs ctypefunc.ctitem = self.ctitem + #ctypefunc.cif_descr = NULL --- already provided as the default CifDescrBuilder(fvarargs, self.ctitem).rawallocate(ctypefunc) return ctypefunc _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit