From patchwork Fri Aug 30 19:03:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D6777: py3: go back to using strings for paths in statprof.py From: phabricator X-Patchwork-Id: 41444 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Fri, 30 Aug 2019 19:03:23 +0000 martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY The code before this paths raises this: TypeError: a bytes-like object is required, not 'str' The issue is that we convert to bytes, then call rsplit() on the bytes with os.sep, which is a string. It seems statprof.py is using strings for paths and 2912b06905dc (py3: use pycompat.fsencode() to convert __file__ to bytes, 2017-02-20) just went too far by using fsencode() there. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D6777 AFFECTED FILES mercurial/statprof.py CHANGE DETAILS To: martinvonz, #hg-reviewers Cc: mercurial-devel diff --git a/mercurial/statprof.py b/mercurial/statprof.py --- a/mercurial/statprof.py +++ b/mercurial/statprof.py @@ -766,7 +766,7 @@ if path in _pathcache: return _pathcache[path] - hgpath = pycompat.fsencode(encoding.__file__).rsplit(os.sep, 2)[0] + hgpath = encoding.__file__.rsplit(os.sep, 2)[0] for p in [hgpath] + sys.path: prefix = p + os.sep if path.startswith(prefix):