Author: Armin Rigo <ar...@tunes.org> Branch: ffi-backend Changeset: r56473:f111f6be66bd Date: 2012-07-26 13:31 +0200 http://bitbucket.org/pypy/pypy/changeset/f111f6be66bd/
Log: Tweak the repr of non-owned structs, as was done in hg/cffi diff --git a/pypy/module/_cffi_backend/cdataobj.py b/pypy/module/_cffi_backend/cdataobj.py --- a/pypy/module/_cffi_backend/cdataobj.py +++ b/pypy/module/_cffi_backend/cdataobj.py @@ -30,8 +30,17 @@ return extra def repr(self): - extra = self._repr_extra() - return self.space.wrap("<cdata '%s' %s>" % (self.ctype.name, extra)) + extra2 = self._repr_extra() + extra1 = '' + if not isinstance(self, W_CDataApplevelOwning): + # it's slightly confusing to get "<cdata 'struct foo' 0x...>" + # because the struct foo is not owned. Trying to make it + # clearer, write in this case "<cdata 'struct foo &' 0x...>". + from pypy.module._cffi_backend import ctypestruct + if isinstance(self.ctype, ctypestruct.W_CTypeStructOrUnion): + extra1 = ' &' + return self.space.wrap("<cdata '%s%s' %s>" % ( + self.ctype.name, extra1, extra2)) def nonzero(self): return self.space.wrap(bool(self._cdata)) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit