Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 50583:58e58ea3dcb8
safehasattr: pass attribute name as string instead of bytes
This is a step toward replacing `util.safehasattr` usage with plain `hasattr`.
The builtin function behave poorly in Python2 but this was fixed in Python3.
These change are done one by one as they tend to have a small odd to trigger
puzzling breackage.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 02 Feb 2023 17:29:39 +0100 |
parents | 2d9ba65a4d0a |
children | 60f9602b413e |
comparison
equal
deleted
inserted
replaced
50582:2d9ba65a4d0a | 50583:58e58ea3dcb8 |
---|---|
1565 rref = weakref.ref(self) | 1565 rref = weakref.ref(self) |
1566 | 1566 |
1567 def checksvfs(path, mode=None): | 1567 def checksvfs(path, mode=None): |
1568 ret = origfunc(path, mode=mode) | 1568 ret = origfunc(path, mode=mode) |
1569 repo = rref() | 1569 repo = rref() |
1570 if repo is None or not util.safehasattr(repo, b'_lockref'): | 1570 if repo is None or not util.safehasattr(repo, '_lockref'): |
1571 return | 1571 return |
1572 if mode in (None, b'r', b'rb'): | 1572 if mode in (None, b'r', b'rb'): |
1573 return | 1573 return |
1574 if path.startswith(repo.sharedpath): | 1574 if path.startswith(repo.sharedpath): |
1575 # truncate name relative to the repository (.hg) | 1575 # truncate name relative to the repository (.hg) |