Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
unicode encoded is bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
zeph committed Aug 29, 2019
1 parent 6888489 commit b92d5b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/testmisc.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_to_unicode_3(self):
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")
Expand Down
5 changes: 3 additions & 2 deletions wicd/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b92d5b0

Please sign in to comment.