mirror of
https://github.com/gryf/wicd.git
synced 2025-12-22 14:07:59 +01:00
unicode encoded is bytes
This commit is contained in:
@@ -137,7 +137,7 @@ class TestMisc(unittest.TestCase):
|
|||||||
self.assertEqual(misc.to_unicode('abcdef'), 'abcdef')
|
self.assertEqual(misc.to_unicode('abcdef'), 'abcdef')
|
||||||
|
|
||||||
def test_to_unicode_4(self):
|
def test_to_unicode_4(self):
|
||||||
self.assertEqual(type(misc.to_unicode('abcdef'.encode('latin-1'))), str)
|
self.assertEqual(type(misc.to_unicode('abcdef'.encode('latin-1'))), bytes)
|
||||||
|
|
||||||
def test_to_unicode_5(self):
|
def test_to_unicode_5(self):
|
||||||
self.assertEqual(misc.to_unicode("berkåk"), "berkåk")
|
self.assertEqual(misc.to_unicode("berkåk"), "berkåk")
|
||||||
|
|||||||
@@ -476,9 +476,10 @@ def sanitize_escaped(s):
|
|||||||
def to_unicode(x):
|
def to_unicode(x):
|
||||||
""" Attempts to convert a string to utf-8. """
|
""" Attempts to convert a string to utf-8. """
|
||||||
# If this is a unicode string, encode it and return
|
# If this is a unicode string, encode it and return
|
||||||
if not isinstance(x, str):
|
if not isinstance(x, bytes):
|
||||||
return x
|
return x
|
||||||
if isinstance(x, str):
|
|
||||||
|
if isinstance(x, bytes):
|
||||||
return x
|
return x
|
||||||
|
|
||||||
x = sanitize_escaped(x)
|
x = sanitize_escaped(x)
|
||||||
|
|||||||
Reference in New Issue
Block a user