Mercurial > hg > mercurial-source
changeset 28359:051b0dcec98b
osutil: implement __enter__ and __exit__ on posixfile
So they can be used as context managers.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 02 Jan 2016 16:41:57 -0800 (2016-01-03) |
parents | 4e27c0a70574 |
children | 2380889f8f52 |
files | mercurial/pure/osutil.py |
diffstat | 1 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/pure/osutil.py +++ b/mercurial/pure/osutil.py @@ -254,3 +254,9 @@ f = posixfile('foo.txt') f.name = 'bla' ''' return self._file.__setattr__(name, value) + + def __enter__(self): + return self._file.__enter__() + + def __exit__(self, exc_type, exc_value, exc_tb): + return self._file.__exit__(exc_type, exc_value, exc_tb)