Mercurial > public > mercurial-scm > hg
comparison mercurial/pycompat.py @ 32859:a05f3675c46a
py3: add a new strurl() which will convert a bytes url to str
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 16 Jun 2017 00:32:52 +0530 |
parents | c9318beb7c1a |
children | f22f39d56bb5 |
comparison
equal
deleted
inserted
replaced
32858:ed1f376090cd | 32859:a05f3675c46a |
---|---|
171 """ | 171 """ |
172 if isinstance(s, builtins.str): | 172 if isinstance(s, builtins.str): |
173 return s | 173 return s |
174 return s.decode(u'latin-1') | 174 return s.decode(u'latin-1') |
175 | 175 |
176 def strurl(url): | |
177 """Converts a bytes url back to str""" | |
178 return url.decode(u'ascii') | |
179 | |
176 def raisewithtb(exc, tb): | 180 def raisewithtb(exc, tb): |
177 """Raise exception with the given traceback""" | 181 """Raise exception with the given traceback""" |
178 raise exc.with_traceback(tb) | 182 raise exc.with_traceback(tb) |
179 | 183 |
180 def getdoc(obj): | 184 def getdoc(obj): |
242 bytechr = chr | 246 bytechr = chr |
243 bytestr = str | 247 bytestr = str |
244 iterbytestr = iter | 248 iterbytestr = iter |
245 sysbytes = identity | 249 sysbytes = identity |
246 sysstr = identity | 250 sysstr = identity |
251 strurl = identity | |
247 | 252 |
248 # this can't be parsed on Python 3 | 253 # this can't be parsed on Python 3 |
249 exec('def raisewithtb(exc, tb):\n' | 254 exec('def raisewithtb(exc, tb):\n' |
250 ' raise exc, None, tb\n') | 255 ' raise exc, None, tb\n') |
251 | 256 |