def errcheck(res, func, args):
    if not res:
        raise IOError
return res
libc.fopen.errcheck = errcheck
file_p = libc.fopen('output.bin', 'wb')
sizeof_item = 1
nitems = libc.fwrite(c_uncompData_p, sizeof_item, c_uncompSize, file_p)
retcode = libc.fclose(file_p)
if nitems != c_uncompSize:
    pass
if retcode != 0:
    pass
Запись бинарного буфера в файл на python