Patchwork [4,of,4] windows: ensure pure posixfile fd doesn't escape by entering context manager

login
register
mail settings
Submitter Matt Harbison
Date Dec. 15, 2018, 8:04 p.m.
Message ID <46761e235265dc2cfb4e.1544904267@Envy>
Download mbox | patch
Permalink /patch/37193/
State Accepted
Headers show

Comments

Matt Harbison - Dec. 15, 2018, 8:04 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1544903706 18000
#      Sat Dec 15 14:55:06 2018 -0500
# Node ID 46761e235265dc2cfb4e8f54c5f7c6f5b7d58906
# Parent  847613113d3ac24106fcd3ca727428b6e02022ae
windows: ensure pure posixfile fd doesn't escape by entering context manager

There are tests in test-revlog-mmapindex.t and test-rebase-mq-skip.t that are
fixed by this, but we usually don't use --pure on Windows.  For whatever reason,
the remaining --pure failures are various errors like  $ENOTDIR$ and "Access is
denied" have a trailing '.'.

Patch

diff --git a/mercurial/pure/osutil.py b/mercurial/pure/osutil.py
--- a/mercurial/pure/osutil.py
+++ b/mercurial/pure/osutil.py
@@ -267,7 +267,8 @@  else:
             return self._file.__setattr__(name, value)
 
         def __enter__(self):
-            return self._file.__enter__()
+            self._file.__enter__()
+            return self
 
         def __exit__(self, exc_type, exc_value, exc_tb):
             return self._file.__exit__(exc_type, exc_value, exc_tb)