mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-13 00:10:03 +00:00
Fix bug in jsonbytes.
This commit is contained in:
parent
bb48974fd8
commit
d5b48e65c7
@ -558,6 +558,12 @@ class JSONBytes(unittest.TestCase):
|
||||
expected
|
||||
)
|
||||
|
||||
def test_dumps_bytes_unicode_separators(self):
|
||||
"""Unicode separators don't prevent the result from being bytes."""
|
||||
result = jsonbytes.dumps_bytes([1, 2], separators=(u',', u':'))
|
||||
self.assertIsInstance(result, bytes)
|
||||
self.assertEqual(result, b"[1,2]")
|
||||
|
||||
|
||||
class FakeGetVersion(object):
|
||||
"""Emulate an object with a get_version."""
|
||||
|
@ -109,7 +109,7 @@ def dumps_bytes(obj, *args, **kwargs):
|
||||
human consumption.
|
||||
"""
|
||||
result = dumps(obj, *args, **kwargs)
|
||||
if PY3:
|
||||
if PY3 or isinstance(result, str):
|
||||
result = result.encode("utf-8")
|
||||
return result
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user