summaryrefslogtreecommitdiffstats
path: root/cython/afc.pxi
diff options
context:
space:
mode:
authorGravatar Dawn K. Isabel2013-06-06 23:33:18 -0400
committerGravatar Dawn K. Isabel2013-06-06 23:33:18 -0400
commita124ee348d7862eaa2eb834246d2b74e3c68b518 (patch)
tree6f774ac7ea2934103b2590d3531720636ab1982c /cython/afc.pxi
parent41ba99ebe3e349f0ba6c0538db99d2335ef7c768 (diff)
downloadlibimobiledevice-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.pxi6
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))