changeset 40937:e11e03f72baf stable

py3: ensure the proxied Windows fd doesn't escape by entering context manager The purpose of the proxy class is to provide the `name` attribute which contains the file path. But in tests that used a context manager, it still blew up complaining that 'int' doesn't have a 'startswith' function.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 15 Dec 2018 01:26:18 -0500
parents 21f5810df848
children 9ae4aed27930
files mercurial/windows.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/windows.py	Wed Dec 12 06:41:19 2018 +0100
+++ b/mercurial/windows.py	Sat Dec 15 01:26:18 2018 -0500
@@ -132,7 +132,10 @@
         self._fp = fp
 
     def __enter__(self):
-        return self._fp.__enter__()
+        self._fp.__enter__()
+        # Return this wrapper for the context manager so that the name is
+        # still available.
+        return self
 
     def __exit__(self, exc_type, exc_value, traceback):
         self._fp.__exit__(exc_type, exc_value, traceback)