unicode encoded is bytes
This commit is contained in:
1 parent
6888489192
commit
b92d5b052e
2 files changed
+4
-3
No files matched your search
+1
-1
@@ -137,7 +137,7 @@ class TestMisc(unittest.TestCase):
|
||||
self.assertEqual(misc.to_unicode('abcdef'), 'abcdef')
|
||||
|
||||
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):
|
||||
self.assertEqual(misc.to_unicode("berkåk"), "berkåk")
|
||||
|
||||
+3
-2
@@ -476,9 +476,10 @@ def sanitize_escaped(s):
|
||||
def to_unicode(x):
|
||||
""" Attempts to convert a string to utf-8. """
|
||||
# If this is a unicode string, encode it and return
|
||||
if not isinstance(x, str):
|
||||
if not isinstance(x, bytes):
|
||||
return x
|
||||
if isinstance(x, str):
|
||||
|
||||
if isinstance(x, bytes):
|
||||
return x
|
||||
|
||||
x = sanitize_escaped(x)
|
||||
|
||||
Reference in new issue
Block a user