On Mon, 2019-02-04 at 08:44 +0900, Masashi Honma wrote: > On 2019/02/04 4:02, Johannes Berg wrote: > > Ok, that's no fun. > > > > However, why not make them take both? We can always assume bytes inside > > the function, and do something like > > > > if isinstance(query, str): > > query = query.encode('ascii') > > > > That way, tests that actually just use plain arguments need no > > modifications at all, but tests that deal with binascii or similar > > things that takes bytes can be converted completely to bytes and not > > have .decode()/.encode() sprinkled over them. > > I can modify wpaspy.py to toke both. Almost cases works fine. > Though, ap_wpa2_eap_ttls_mschapv2_utf8 fails. > Because it includes non printable SSID. > So it is recognized as non-string. > > def request(self, cmd, timeout=10): > if isinstance(cmd, str): > if self.udp: > self.s.sendto(self.cookie + cmd.encode(), self.sockaddr) > else: > # we specify utf-8 for utf-8 SSID > self.s.send(cmd.encode('utf-8')) > else: > if self.udp: > self.s.sendto(self.cookie + cmd, self.sockaddr) > else: > self.s.send(cmd) So you say you want to use utf-8 instead of ASCII? I guess that's fine. We could debate whether the encoding should then be done by the test itself, which knows to expect UTF-8, or the framework like here. It feels slightly safer to me to enforce ASCII in the framework, and have this particular test .encode('utf-8') (and use b'' for other strings) so that it's clear in the test that it actually wants to send utf-8 encoded bytes to the supplicant binary. The thing is, the supplicant doesn't actually look at the encoding in any way, it just treats it as opaque bytes. But the additional "safety" that I'm thinking of would anyway be something we never had with python2, so I guess it doesn't matter. johannes _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap