On 2019/02/08 23:07, Jouni Malinen wrote:
What is the benefit of not trying to catch the exception if it might never be raised on some python versions? I'm not sure how this would make debugging more difficult here.
The try statement in vm_read_stdout() expects only "[Errno 11] Resource temporarily unavailable" exception. Then, I would like to write like this. By this code, I can recognize ENOMEM or other exceptions occurred. try: out = vm['proc'].stdout.read() if out == None: return False out = out.decode() except IOError as e: if e.errno == errno.EAGAIN: return False raise e I will send this part as RFC.
I have strong preference on not having to maintain duplicated code and also on not seeing sys.version_info being used anywhere unless it is absolutely necessary to do so for functionality or avoiding overly complex implementation. At least for me, this: try: err = vm[i]['proc'].stderr.read() if err != None: err = err.decode() vm[i]['err'] += err logger.debug("VM[%d] stderr.read[%s]" % (i, err)) except: pass looks much cleaner than this: if sys.version_info[0] > 2: err = vm[i]['proc'].stderr.read() if err != None: err = err.decode() vm[i]['err'] += err logger.debug("VM[%d] stderr.read[%s]" % (i, err)) else: try: err = vm[i]['proc'].stderr.read() vm[i]['err'] += err logger.debug("VM[%d] stderr.read[%s]" % (i, err)) except: pass
Ok, my previous patch was ugly indeed. I will rewrite. Masashi Honma. _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap