Re: [PATCH 4/4] tests: Change handling of reading non blocked empty stream for python3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 08, 2019 at 08:51:24PM +0900, Masashi Honma wrote:
> My purpose of this patch is not to catch exception if not needed.
> Because catching exception makes debugging more difficult.
> Indeed, sometimes I needed to comment out try statements temporarily
> while doing python2 to 3 project.

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.

> Which do you like ?

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

-- 
Jouni Malinen                                            PGP id EFC895FA

_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux