PyQIODevice: Add context manager support.
This commit is contained in:
parent
b8dd71a343
commit
6452c8f883
@ -260,10 +260,15 @@ class PyQIODevice(io.BufferedIOBase):
|
||||
|
||||
Args:
|
||||
mode: QIODevice::OpenMode flags.
|
||||
|
||||
Return:
|
||||
A contextlib.closing() object so this can be used as
|
||||
contextmanager.
|
||||
"""
|
||||
ok = self.dev.open(mode)
|
||||
if not ok:
|
||||
raise OSError(self.dev.errorString())
|
||||
return contextlib.closing(self)
|
||||
|
||||
def close(self):
|
||||
"""Close the underlying device."""
|
||||
|
Loading…
Reference in New Issue
Block a user