pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers.
REVISION SUMMARY pycompat.py has functions strurl and bytesurl which decodes and encodes the url passed on Python 3 respectively. In some cases, strurl gets a url which is already str and bytesurl gets a url which is already bytes. Let's prevent encoding or decoding the values again if not required. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2472 AFFECTED FILES mercurial/pycompat.py CHANGE DETAILS diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -192,11 +192,13 @@ def strurl(url): """Converts a bytes url back to str""" - return url.decode(u'ascii') + if isinstance(url, bytes): + return url.decode(u'ascii') def bytesurl(url): """Converts a str url to bytes by encoding in ascii""" - return url.encode(u'ascii') + if isinstance(url, str): + return url.encode(u'ascii') def raisewithtb(exc, tb): """Raise exception with the given traceback""" To: pulkit, #hg-reviewers Cc: mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel