picop.cyfileobject#

File-object helpers.

picop.cyfileobject.file_from_fd(fd, name, mode, buffering, encoding, errors, newline=-1, closefd=1)#

Wrap OS fd as a Python file via PyFile_FromFd.

Notes

name / mode / optional codec strings must be bytes, not str.

Parameters:
Return type:

object

picop.cyfileobject.file_getline(p, n=-1)#

Read a line from file p via PyFile_GetLine. :type p: object :param p: :type n: int, default: -1 :param n:

Return type:

object

picop.cyfileobject.file_write_cstr(s, p)#

Write C string s to file p via PyFile_WriteString.

Notes

s must be bytes, not str. Returns 0 on success; errors raise — do not use the status as a bool. Alias of file_write_string.

Parameters:
Return type:

int

picop.cyfileobject.file_write_object(obj, p, flags=0)#

Write obj to file p via PyFile_WriteObject.

Notes

Returns 0 on success; errors raise — do not use the status as a bool.

Parameters:
Return type:

int