[PATCH 2 of 4] windows: ensure mixedfilemodewrapper fd doesn't escape by entering context mgr

Matt Harbison mharbison72 at gmail.com
Sat Dec 15 15:04:25 EST 2018


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1544899294 18000
#      Sat Dec 15 13:41:34 2018 -0500
# Node ID d40ef8f0cd2cce5b41e48924fc2a3d486b4c534d
# Parent  068910232e124a50a13fd7444844d9151db48d6b
windows: ensure mixedfilemodewrapper fd doesn't escape by entering context mgr

Otherwise it seems that the special read and write handling would be bypassed.

diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -70,7 +70,8 @@ class mixedfilemodewrapper(object):
         object.__setattr__(self, r'_lastop', 0)
 
     def __enter__(self):
-        return self._fp.__enter__()
+        self._fp.__enter__()
+        return self
 
     def __exit__(self, exc_type, exc_val, exc_tb):
         self._fp.__exit__(exc_type, exc_val, exc_tb)


More information about the Mercurial-devel mailing list