Revert "Explicitly raise ValueError in to_primitive"

This reverts commit 3727b2d6e0.

It breaks nova's test, need log warning before we make major release.

Change-Id: Ibbfde6207fc8c066155758c7c1aa1521b95d4db1
This commit is contained in:
ChangBo Guo(gcb) 2017-07-17 23:26:56 +08:00
parent 790d1d12d0
commit bbee6d1aa1
2 changed files with 2 additions and 2 deletions

View File

@ -167,7 +167,7 @@ def to_primitive(value, convert_instances=False, convert_datetime=True,
# __iter__ defined but it isn't callable as list().
return six.text_type(value)
raise ValueError("Cannot convert %r to primitive" % (value,))
return value
JSONEncoder = json.JSONEncoder

View File

@ -254,7 +254,7 @@ class ToPrimitiveTestCase(test_base.BaseTestCase):
self.assertEqual(dict(b=1),
jsonutils.to_primitive(x, convert_instances=True))
self.assertRaises(ValueError, jsonutils.to_primitive, x)
self.assertEqual(x, jsonutils.to_primitive(x))
def test_typeerror(self):
x = bytearray # Class, not instance