# HG changeset patch # User Adrian Buehlmann # Date 2015-02-06 22:40:46 # Node ID c6666395fdd2e72c06d1f4c5fd5966cff339f388 # Parent 4e02418b4236a07049ad5e71836decfa8a8120b6 windows: adjust doc string and comments of posixfile() The doc string of osutil.posixfile includes (line 611): "On error, this function may raise either a WindowsError or an IOError." which is most likely correct, but does not fit for this function here anymore, as we do fold WindowsError to IOError here specifically. And this function is now a bit more than just an exception-wrapper, as it has been expanded to additionally sanitize the unloved seek/tell behavior of Windows. (Self-disclosure: This patch is entirely untested at the time of its publication, as I'm currently not using this version myself. I send it in hopes that it will reduce potential future confusion. CC-ing Matt Harbison) diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -28,10 +28,10 @@ unlink = win32.unlink umask = 0022 _SEEK_END = 2 # os.SEEK_END was introduced in Python 2.5 -# wrap osutil.posixfile to provide friendlier exceptions def posixfile(name, mode='r', buffering=-1): + '''Open a file with even more POSIX-like semantics''' try: - fp = osutil.posixfile(name, mode, buffering) + fp = osutil.posixfile(name, mode, buffering) # may raise WindowsError # The position when opening in append mode is implementation defined, so # make it consistent with other platforms, which position at EOF. @@ -40,8 +40,8 @@ def posixfile(name, mode='r', buffering= return fp except WindowsError, err: + # convert to a friendlier exception raise IOError(err.errno, '%s: %s' % (name, err.strerror)) -posixfile.__doc__ = osutil.posixfile.__doc__ class winstdout(object): '''stdout on windows misbehaves if sent through a pipe'''