comparison mercurial/windows.py @ 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 ab04ce6f0674
children 9ae4aed27930
comparison
equal deleted inserted replaced
40926:21f5810df848 40937:e11e03f72baf
130 def __init__(self, name, fp): 130 def __init__(self, name, fp):
131 self.name = name 131 self.name = name
132 self._fp = fp 132 self._fp = fp
133 133
134 def __enter__(self): 134 def __enter__(self):
135 return self._fp.__enter__() 135 self._fp.__enter__()
136 # Return this wrapper for the context manager so that the name is
137 # still available.
138 return self
136 139
137 def __exit__(self, exc_type, exc_value, traceback): 140 def __exit__(self, exc_type, exc_value, traceback):
138 self._fp.__exit__(exc_type, exc_value, traceback) 141 self._fp.__exit__(exc_type, exc_value, traceback)
139 142
140 def __iter__(self): 143 def __iter__(self):