D6777: py3: go back to using strings for paths in statprof.py
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Fri Aug 30 19:03:23 UTC 2019
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 <https://phab.mercurial-scm.org/rHG2912b06905dceb4fd668cd0a8d815ac9a001664b> (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
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):
To: martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list