mercurial/encoding.py
changeset 36549 3696efeab66f
parent 34218 aa877860d4d7
child 36797 d4c760c997cd
equal deleted inserted replaced
36548:086fc71fbb09 36549:3696efeab66f
   179     try:
   179     try:
   180         u = s.decode(_sysstr(encoding), _sysstr(encodingmode))
   180         u = s.decode(_sysstr(encoding), _sysstr(encodingmode))
   181         return u.encode("utf-8")
   181         return u.encode("utf-8")
   182     except UnicodeDecodeError as inst:
   182     except UnicodeDecodeError as inst:
   183         sub = s[max(0, inst.start - 10):inst.start + 10]
   183         sub = s[max(0, inst.start - 10):inst.start + 10]
   184         raise error.Abort("decoding near '%s': %s!" % (sub, inst))
   184         raise error.Abort("decoding near '%s': %s!"
       
   185                           % (sub, pycompat.bytestr(inst)))
   185     except LookupError as k:
   186     except LookupError as k:
   186         raise error.Abort(k, hint="please check your locale settings")
   187         raise error.Abort(k, hint="please check your locale settings")
   187 
   188 
   188 def unitolocal(u):
   189 def unitolocal(u):
   189     """Convert a unicode string to a byte string of local encoding"""
   190     """Convert a unicode string to a byte string of local encoding"""