@@ -307,7 +307,7 @@ def setEssid(self, essid):
307307 if len (essid ) > pythonwifi .flags .IW_ESSID_MAX_SIZE :
308308 raise OverflowError (errno .EOVERFLOW , os .strerror (errno .EOVERFLOW ))
309309 if (sys .version_info [0 ] == 3 ):
310- essid = bytes (essid ,'latin-1 ' )
310+ essid = bytes (essid ,'unicode-escape ' )
311311 iwpoint = Iwpoint (essid , 1 )
312312 status , result = self .iwstruct .iw_set_ext (self .ifname ,
313313 pythonwifi .flags .SIOCSIWESSID ,
@@ -429,7 +429,7 @@ def setKey(self, key, index=1):
429429 cooked_key = map (chr , raw_key )
430430
431431 if (sys .version_info [0 ] == 3 ):
432- cooked_key = bytes (cooked_key , 'latin-1 ' )
432+ cooked_key = bytes (cooked_key , 'unicode-escape ' )
433433
434434 iwpoint = Iwpoint (cooked_key ,
435435 index + pythonwifi .flags .IW_ENCODE_ENABLED )
@@ -738,7 +738,12 @@ def getWirelessName(self):
738738 """
739739 status , result = self .iwstruct .iw_get_ext (self .ifname ,
740740 pythonwifi .flags .SIOCGIWNAME )
741- return result .tostring ().strip ('\x00 ' )
741+
742+ result = result .tostring ().strip (b'\x00 ' )
743+ if (sys .version_info [0 ] == 2 ):
744+ return result
745+ else :
746+ return result .decode ("unicode-escape" )
742747
743748 def getEncryption (self ):
744749 """ Returns the encryption status.
@@ -815,7 +820,7 @@ def getEssid(self):
815820 if (sys .version_info [0 ] == 2 ):
816821 return result
817822 else :
818- return result .decode ("latin-1 " )
823+ return result .decode ("unicode-escape " )
819824
820825 def getMode (self ):
821826 """ Returns currently set operation mode.
@@ -1033,7 +1038,7 @@ def pack_test(self, string, buffsize):
10331038 if (sys .version_info [0 ] == 2 ):
10341039 buff = array .array ('c' , string + '\0 ' * buffsize )
10351040 else :
1036- var_bytes = bytes (string , 'latin-1 ' )
1041+ var_bytes = bytes (string , 'unicode-escape ' )
10371042 buff = array .array ('B' , var_bytes + b'\0 ' * buff )
10381043 caddr_t , length = buff .buffer_info ()
10391044 s = struct .pack ('PHH' , caddr_t , length , 1 )
@@ -1052,7 +1057,7 @@ def iw_get_ext(self, ifname, request, data=None):
10521057 if (sys .version_info [0 ] == 2 ):
10531058 ifreq = array .array ('c' , ifname + '\0 ' * buff )
10541059 else :
1055- var_bytes = bytes (ifname , 'latin-1 ' )
1060+ var_bytes = bytes (ifname , 'unicode-escape ' )
10561061 ifreq = array .array ('B' , var_bytes + b'\0 ' * buff )
10571062 # put some additional data behind the interface name
10581063 if data is not None :
@@ -1564,7 +1569,7 @@ def addEvent(self, cmd, data):
15641569 data_string = data
15651570 if (sys .version_info [0 ] == 3 ):
15661571 # convert byte to string
1567- data_string = data .decode ("latin-1 " )
1572+ data_string = data .decode ("unicode-escape " )
15681573 if ((cmd in range (pythonwifi .flags .SIOCIWFIRST ,
15691574 pythonwifi .flags .SIOCIWLAST + 1 )) or
15701575 (cmd in range (pythonwifi .flags .IWEVFIRST ,
0 commit comments