Merge "Revert "Call safe_encode() instead of str()""
This commit is contained in:
@@ -20,7 +20,6 @@ import netaddr
|
|||||||
|
|
||||||
from nova.network import model as network_model
|
from nova.network import model as network_model
|
||||||
from nova.openstack.common.gettextutils import _
|
from nova.openstack.common.gettextutils import _
|
||||||
from nova.openstack.common import strutils
|
|
||||||
from nova.openstack.common import timeutils
|
from nova.openstack.common import timeutils
|
||||||
|
|
||||||
|
|
||||||
@@ -59,8 +58,6 @@ def str_or_none(val):
|
|||||||
"""Attempt to stringify a value, or None."""
|
"""Attempt to stringify a value, or None."""
|
||||||
if val is None:
|
if val is None:
|
||||||
return val
|
return val
|
||||||
elif isinstance(val, basestring):
|
|
||||||
return strutils.safe_encode(val)
|
|
||||||
else:
|
else:
|
||||||
return str(val)
|
return str(val)
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ class TestUtils(test.TestCase):
|
|||||||
self.assertEqual(utils.str_or_none('foo'), 'foo')
|
self.assertEqual(utils.str_or_none('foo'), 'foo')
|
||||||
self.assertEqual(utils.str_or_none(1), '1')
|
self.assertEqual(utils.str_or_none(1), '1')
|
||||||
self.assertEqual(utils.str_or_none(None), None)
|
self.assertEqual(utils.str_or_none(None), None)
|
||||||
self.assertEqual(utils.str_or_none(u'\u30bdfoo'), '\xe3\x82\xbdfoo')
|
|
||||||
|
|
||||||
def test_ip_or_none(self):
|
def test_ip_or_none(self):
|
||||||
ip4 = netaddr.IPAddress('1.2.3.4', 4)
|
ip4 = netaddr.IPAddress('1.2.3.4', 4)
|
||||||
|
|||||||
Reference in New Issue
Block a user