[PATCH 1 of 4] py3: ensure the proxied Windows fd doesn't escape by entering context manager
Matt Harbison
mharbison72 at gmail.com
Sat Dec 15 20:04:24 UTC 2018
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1544855178 18000
# Sat Dec 15 01:26:18 2018 -0500
# Node ID 068910232e124a50a13fd7444844d9151db48d6b
# Parent 5817c3b186a7799ecc3130493ba134b55cd4ba07
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.
diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -132,7 +132,10 @@ class fdproxy(object):
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)
More information about the Mercurial-devel
mailing list