Show More
@@ -13,6 +13,7 b' import time' | |||
|
13 | 13 | |
|
14 | 14 | from . import ( |
|
15 | 15 | encoding, |
|
16 | error, | |
|
16 | 17 | hbisect, |
|
17 | 18 | node, |
|
18 | 19 | pycompat, |
@@ -233,6 +234,13 b' def json(obj, paranoid=True):' | |||
|
233 | 234 | return pycompat.bytestr(obj) |
|
234 | 235 | elif isinstance(obj, bytes): |
|
235 | 236 | return '"%s"' % encoding.jsonescape(obj, paranoid=paranoid) |
|
237 | elif isinstance(obj, str): | |
|
238 | # This branch is unreachable on Python 2, because bytes == str | |
|
239 | # and we'll return in the next-earlier block in the elif | |
|
240 | # ladder. On Python 3, this helps us catch bugs before they | |
|
241 | # hurt someone. | |
|
242 | raise error.ProgrammingError( | |
|
243 | 'Mercurial only does output with bytes on Python 3: %r' % obj) | |
|
236 | 244 | elif util.safehasattr(obj, 'keys'): |
|
237 | 245 | out = ['"%s": %s' % (encoding.jsonescape(k, paranoid=paranoid), |
|
238 | 246 | json(v, paranoid)) |
General Comments 0
You need to be logged in to leave comments.
Login now