exception.py 文件源码

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

项目:PythonForWindows 作者: hakril 项目源码 文件源码
def new_aligned(cls):
        """Return a new :class:`ECONTEXT64` aligned on 16 bits

           temporary workaround or horrible hack ? choose your side
        """
        size = ctypes.sizeof(cls)
        nb_qword = (size + 8) / ctypes.sizeof(ULONGLONG)
        buffer = (nb_qword * ULONGLONG)()
        struct_address = ctypes.addressof(buffer)
        if (struct_address & 0xf) not in [0, 8]:
            raise ValueError("ULONGLONG array not aligned on 8")
        if (struct_address & 0xf) == 8:
            struct_address += 8
        self = cls.from_address(struct_address)
        # Keep the raw buffer alive
        self._buffer = buffer
        return self
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号