hgext/convert/common.py
changeset 49025 06de08b36c82
parent 49004 f254fc73d956
child 49032 fd5b8e696b75
equal deleted inserted replaced
49024:78f1de3f4be7 49025:06de08b36c82
   244 
   244 
   245     def recode(self, s, encoding=None):
   245     def recode(self, s, encoding=None):
   246         if not encoding:
   246         if not encoding:
   247             encoding = self.encoding or b'utf-8'
   247             encoding = self.encoding or b'utf-8'
   248 
   248 
   249         if isinstance(s, pycompat.unicode):
   249         if isinstance(s, str):
   250             return s.encode("utf-8")
   250             return s.encode("utf-8")
   251         try:
   251         try:
   252             return s.decode(pycompat.sysstr(encoding)).encode("utf-8")
   252             return s.decode(pycompat.sysstr(encoding)).encode("utf-8")
   253         except UnicodeError:
   253         except UnicodeError:
   254             try:
   254             try: