diff options
author | Dawn K. Isabel | 2013-06-06 23:33:18 -0400 |
---|---|---|
committer | Dawn K. Isabel | 2013-06-06 23:33:18 -0400 |
commit | a124ee348d7862eaa2eb834246d2b74e3c68b518 (patch) | |
tree | 6f774ac7ea2934103b2590d3531720636ab1982c /cython/afc.pxi | |
parent | 41ba99ebe3e349f0ba6c0538db99d2335ef7c768 (diff) | |
download | libimobiledevice-a124ee348d7862eaa2eb834246d2b74e3c68b518.tar.gz libimobiledevice-a124ee348d7862eaa2eb834246d2b74e3c68b518.tar.bz2 |
cython: Add support for using Python 'with' statement when opening AfcFile
Diffstat (limited to 'cython/afc.pxi')
-rw-r--r-- | cython/afc.pxi | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/cython/afc.pxi b/cython/afc.pxi index 6df9b45..1d3b366 100644 --- a/cython/afc.pxi +++ b/cython/afc.pxi @@ -116,6 +116,12 @@ cdef class AfcFile(Base): def __init__(self, *args, **kwargs): raise TypeError("AfcFile cannot be instantiated") + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + self.close() + cpdef close(self): self.handle_error(afc_file_close(self._client._c_client, self._c_handle)) |