summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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))