Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/pycompat.py @ 35944:fc44c2657dc5
py3: drop b'' from repr() of smartset
cmdutil._maybebytestr() is moved to pycompat.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 27 Jan 2018 17:46:37 +0900 |
parents | 1a31111e6239 |
children | 04984f2e50ae |
comparison
equal
deleted
inserted
replaced
35943:1a31111e6239 | 35944:fc44c2657dc5 |
---|---|
159 | 159 |
160 def iterbytestr(s): | 160 def iterbytestr(s): |
161 """Iterate bytes as if it were a str object of Python 2""" | 161 """Iterate bytes as if it were a str object of Python 2""" |
162 return map(bytechr, s) | 162 return map(bytechr, s) |
163 | 163 |
164 def maybebytestr(s): | |
165 """Promote bytes to bytestr""" | |
166 if isinstance(s, bytes): | |
167 return bytestr(s) | |
168 return s | |
169 | |
164 def sysbytes(s): | 170 def sysbytes(s): |
165 """Convert an internal str (e.g. keyword, __doc__) back to bytes | 171 """Convert an internal str (e.g. keyword, __doc__) back to bytes |
166 | 172 |
167 This never raises UnicodeEncodeError, but only ASCII characters | 173 This never raises UnicodeEncodeError, but only ASCII characters |
168 can be round-trip by sysstr(sysbytes(s)). | 174 can be round-trip by sysstr(sysbytes(s)). |
265 import cStringIO | 271 import cStringIO |
266 | 272 |
267 bytechr = chr | 273 bytechr = chr |
268 bytestr = str | 274 bytestr = str |
269 iterbytestr = iter | 275 iterbytestr = iter |
276 maybebytestr = identity | |
270 sysbytes = identity | 277 sysbytes = identity |
271 sysstr = identity | 278 sysstr = identity |
272 strurl = identity | 279 strurl = identity |
273 bytesurl = identity | 280 bytesurl = identity |
274 | 281 |