Mercurial > public > mercurial-scm > hg-stable
diff mercurial/util.py @ 33038:ce96efec8112
py3: add utility to forward __str__() to __bytes__()
It calls unifromlocal() instead of sysstr() because __bytes__() may contain
locale-dependent values such as paths.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 24 Jun 2017 13:48:04 +0900 |
parents | 19b0fd4b5570 |
children | 4c5af472a599 |
line wrap: on
line diff
--- a/mercurial/util.py Sat Jun 24 13:20:30 2017 +0900 +++ b/mercurial/util.py Sat Jun 24 13:48:04 2017 +0900 @@ -2740,7 +2740,7 @@ attrs.append('%s: %r' % (a, v)) return '<url %s>' % ', '.join(attrs) - def __str__(self): + def __bytes__(self): r"""Join the URL's components back into a URL string. Examples: @@ -2774,9 +2774,6 @@ >>> print url(r'file:///D:\data\hg') file:///D:\data\hg """ - return encoding.strfromlocal(self.__bytes__()) - - def __bytes__(self): if self._localpath: s = self.path if self.scheme == 'bundle': @@ -2820,6 +2817,8 @@ s += '#' + urlreq.quote(self.fragment, safe=self._safepchars) return s + __str__ = encoding.strmethod(__bytes__) + def authinfo(self): user, passwd = self.user, self.passwd try: