backend_ctypes.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:git_intgrtn_aws_s3 作者: droidlabour 项目源码 文件源码
def gcp(self, cdata, destructor):
        BType = self.typeof(cdata)

        if destructor is None:
            if not (hasattr(BType, '_gcp_type') and
                    BType._gcp_type is BType):
                raise TypeError("Can remove destructor only on a object "
                                "previously returned by ffi.gc()")
            cdata._destructor = None
            return None

        try:
            gcp_type = BType._gcp_type
        except AttributeError:
            class CTypesDataGcp(BType):
                __slots__ = ['_orig', '_destructor']
                def __del__(self):
                    if self._destructor is not None:
                        self._destructor(self._orig)
            gcp_type = BType._gcp_type = CTypesDataGcp
        new_cdata = self.cast(gcp_type, cdata)
        new_cdata._orig = cdata
        new_cdata._destructor = destructor
        return new_cdata
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号