D7944: localrepo: handle ValueError during repository opening

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Sat Jan 18 21:18:58 UTC 2020


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Python 3.8 can raise ValueError on attempt of an I/O operation
  against an illegal path. This was causing test-remotefilelog-gc.t
  to fail on Python 3.8.
  
  This commit teaches repository opening to handle ValueError
  and re-raise an Abort on failure.
  
  An arguably better solution would be to implement this logic
  in the vfs layer. But that seems like a bag of worms and I don't
  want to go down that rabbit hole. Until users report uncaught
  ValueError exceptions in the wild, I think it is fine to patch
  this at the only occurrence our test harness is finding it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7944

AFFECTED FILES
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -504,6 +504,11 @@
         except OSError as e:
             if e.errno != errno.ENOENT:
                 raise
+        except ValueError as e:
+            # Can be raised on Python 3.8 when path is invalid.
+            raise error.Abort(
+                _(b'invalid path %s: %s') % (path, pycompat.bytestr(e))
+            )
 
         raise error.RepoError(_(b'repository %s not found') % path)
 



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list