Patchwork D8302: hg: make _local() behave consistently on Python 3.8 (issue6287)

login
register
mail settings
Submitter phabricator
Date March 19, 2020, 8:45 a.m.
Message ID <51d2c9d68693ea4c20e54f90368a1f72@localhost.localdomain>
Download mbox | patch
Permalink /patch/45827/
State Not Applicable
Headers show

Comments

phabricator - March 19, 2020, 8:45 a.m.
Closed by commit rHG6a8738dc4a01: hg: make _local() behave consistently on Python 3.8 (issue6287) (authored by durin42).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8302?vs=20827&id=20831

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8302/new/

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

AFFECTED FILES
  mercurial/hg.py

CHANGE DETAILS




To: durin42, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -60,12 +60,19 @@ 
     path = util.expandpath(util.urllocalpath(path))
 
     try:
-        isfile = os.path.isfile(path)
+        # we use os.stat() directly here instead of os.path.isfile()
+        # because the latter started returning `False` on invalid path
+        # exceptions starting in 3.8 and we care about handling
+        # invalid paths specially here.
+        st = os.stat(path)
+        isfile = stat.S_ISREG(st.st_mode)
     # Python 2 raises TypeError, Python 3 ValueError.
     except (TypeError, ValueError) as e:
         raise error.Abort(
             _(b'invalid path %s: %s') % (path, pycompat.bytestr(e))
         )
+    except OSError:
+        isfile = False
 
     return isfile and bundlerepo or localrepo