Patchwork D7621: pycompat: allow pycompat.sysbytes() even if input already is bytes

login
register
mail settings
Submitter phabricator
Date Dec. 15, 2019, 3:11 a.m.
Message ID <0c1ffa3ffd8d89a4931e06c34c2c1f91@localhost.localdomain>
Download mbox | patch
Permalink /patch/43840/
State Not Applicable
Headers show

Comments

phabricator - Dec. 15, 2019, 3:11 a.m.
Closed by commit rHG66af68d4c751: pycompat: allow pycompat.sysbytes() even if input already is bytes (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7621?vs=18651&id=18730

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

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

AFFECTED FILES
  mercurial/pycompat.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers, dlax, indygreg
Cc: mercurial-devel

Patch

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -253,6 +253,8 @@ 
         This never raises UnicodeEncodeError, but only ASCII characters
         can be round-trip by sysstr(sysbytes(s)).
         """
+        if isinstance(s, bytes):
+            return s
         return s.encode('utf-8')
 
     def sysstr(s):