diff --git a/mercurial/i18n.py b/mercurial/i18n.py --- a/mercurial/i18n.py +++ b/mercurial/i18n.py @@ -12,7 +12,10 @@ import locale import os import sys -from . import encoding +from . import ( + encoding, + pycompat, +) # modelled after templater.templatepath: if getattr(sys, 'frozen', None) is not None: @@ -85,7 +88,8 @@ def gettext(message): # means u.encode(sys.getdefaultencoding()).decode(enc). Since # the Python encoding defaults to 'ascii', this fails if the # translated string use non-ASCII characters. - _msgcache[message] = u.encode(encoding.encoding, "replace") + encodingstr = pycompat.sysstr(encoding.encoding) + _msgcache[message] = u.encode(encodingstr, "replace") except LookupError: # An unknown encoding results in a LookupError. _msgcache[message] = message diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t --- a/tests/test-check-py3-compat.t +++ b/tests/test-check-py3-compat.t @@ -120,53 +120,53 @@ mercurial/httpconnection.py: error importing: Can't mix strings and bytes in path components (error at i18n.py:*) mercurial/httppeer.py: error importing: Can't mix strings and bytes in path components (error at i18n.py:*) mercurial/i18n.py: error importing module: bytes expected, not str (line *) - mercurial/keepalive.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/localrepo.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/lock.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/mail.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/manifest.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/match.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/mdiff.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/merge.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/minirst.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/namespaces.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/obsolete.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/patch.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/pathutil.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/peer.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/profiling.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/pushkey.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/pvec.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/registrar.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/repair.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/repoview.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/revlog.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/revset.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/scmutil.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/scmwindows.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/similar.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/simplemerge.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/sshpeer.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/sshserver.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/sslutil.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/statichttprepo.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/store.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/streamclone.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/subrepo.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/tagmerge.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/tags.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/templatefilters.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/templatekw.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/templater.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/transaction.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/ui.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/unionrepo.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/url.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/util.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) - mercurial/verify.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) + mercurial/keepalive.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/localrepo.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/lock.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/mail.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/manifest.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/match.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/mdiff.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/merge.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/minirst.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/namespaces.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/obsolete.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/patch.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/pathutil.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/peer.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/profiling.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/pushkey.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/pvec.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/registrar.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/repair.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/repoview.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/revlog.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/revset.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/scmutil.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/scmwindows.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/similar.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/simplemerge.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/sshpeer.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/sshserver.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/sslutil.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/statichttprepo.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/store.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/streamclone.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/subrepo.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/tagmerge.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/tags.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/templatefilters.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/templatekw.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/templater.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/transaction.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/ui.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/unionrepo.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/url.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/util.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) + mercurial/verify.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) mercurial/win32.py: error importing module: No module named 'msvcrt' (line *) mercurial/windows.py: error importing module: No module named 'msvcrt' (line *) - mercurial/wireproto.py: error importing: encode() argument 1 must be str, not bytes (error at i18n.py:*) + mercurial/wireproto.py: error importing: encode() argument 2 must be str, not bytes (error at i18n.py:*) #endif