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

login
register
mail settings
Submitter Matt Harbison
Date Dec. 15, 2018, 8:04 p.m.
Message ID <d40ef8f0cd2cce5b41e4.1544904265@Envy>
Download mbox | patch
Permalink /patch/37191/
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 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.

Patch

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)