Patchwork [2,of,5] py3: pass a system-string filename to sub-classes of IOError

login
register
mail settings
Submitter Yuya Nishihara
Date March 3, 2018, 5:12 p.m.
Message ID <e246d075d3d8b115b0cc.1520097150@mimosa>
Download mbox | patch
Permalink /patch/28790/
State Accepted
Headers show

Comments

Yuya Nishihara - March 3, 2018, 5:12 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1520089693 18000
#      Sat Mar 03 10:08:13 2018 -0500
# Node ID e246d075d3d8b115b0cc40c7c99de94f40a17f15
# Parent  0f60e72e6dfb91bdf3d9d3e992e8b2e5b04d1d7b
py3: pass a system-string filename to sub-classes of IOError

Patch

diff --git a/mercurial/lock.py b/mercurial/lock.py
--- a/mercurial/lock.py
+++ b/mercurial/lock.py
@@ -198,9 +198,10 @@  class lock(object):
                         return
                     locker = self._testlock(locker)
                     if locker is not None:
-                        raise error.LockHeld(errno.EAGAIN,
-                                             self.vfs.join(self.f), self.desc,
-                                             locker)
+                        raise error.LockHeld(
+                            errno.EAGAIN,
+                            encoding.strfromlocal(self.vfs.join(self.f)),
+                            self.desc, locker)
                 else:
                     raise error.LockUnavailable(why.errno, why.strerror,
                                                 why.filename, self.desc)
@@ -209,7 +210,8 @@  class lock(object):
             # use empty locker to mean "busy for frequent lock/unlock
             # by many processes"
             raise error.LockHeld(errno.EAGAIN,
-                                 self.vfs.join(self.f), self.desc, "")
+                                 encoding.strfromlocal(self.vfs.join(self.f)),
+                                 self.desc, "")
 
     def _readlock(self):
         """read lock and return its value
diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py
+++ b/mercurial/statichttprepo.py
@@ -206,7 +206,7 @@  class statichttprepository(localrepo.loc
         return statichttppeer(self)
 
     def wlock(self, wait=True):
-        raise error.LockUnavailable(0, _('lock not available'), 'lock',
+        raise error.LockUnavailable(0, _('lock not available'), r'lock',
                                     _('cannot lock static-http repository'))
 
     def lock(self, wait=True):