Patchwork D12343: lsprof: remove some Python 2.7 compatibility code

login
register
mail settings
Submitter phabricator
Date March 4, 2022, 3:32 a.m.
Message ID <differential-rev-PHID-DREV-fo7wexbdqpelh6psjmdo-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50682/
State New
Headers show

Comments

phabricator - March 4, 2022, 3:32 a.m.
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/lsprof.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/lsprof.py b/mercurial/lsprof.py
--- a/mercurial/lsprof.py
+++ b/mercurial/lsprof.py
@@ -117,9 +117,7 @@ 
 
 def label(code):
     if isinstance(code, str):
-        if sys.version_info.major >= 3:
-            code = code.encode('latin-1')
-        return code
+        return code.encode('latin-1')
     try:
         mname = _fn2mod[code.co_filename]
     except KeyError:
@@ -136,7 +134,4 @@ 
 
     res = '%s:%d(%s)' % (mname, code.co_firstlineno, code.co_name)
 
-    if sys.version_info.major >= 3:
-        res = res.encode('latin-1')
-
-    return res
+    return res.encode('latin-1')