Re: [PATCH] selftests/tpm2: Change exception handling to be Python 3 compatible

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

 



On 14 Apr 2020, at 09:38, Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> wrote:
> OK, I'm aware about the dynamic nature but in this case it is somewhat
> counter intuitive since it is part of the exception clause. You'd except
> the Python interpreter to complain.

I agree.

> So, is Flake8 like the standard to be used?

Pretty much, yes. There is also Pylint though. Among other things, they
both check for PEP 8 (official) coding style compliance.

Cheers,
Ezra.

> On 14 Apr 2020, at 09:38, Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> wrote:
> 
> On Tue, Apr 14, 2020 at 07:45:33AM +0200, Ezra Buehler wrote:
>> Hi Jarkko,
>> 
>> On 13 Apr 2020, at 20:04, Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> wrote:
>>> 
>>> On Mon, Apr 13, 2020 at 07:02:20AM +0200, Ezra Buehler wrote:
>>>> Hi Jarkko,
>>>> 
>>>> On 12 Apr 2020, at 19:07, Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> wrote:
>>>>> 
>>>>> On Sun, Apr 12, 2020 at 05:02:27PM +0200, Ezra Buehler wrote:
>>>>>> Hi Jarkkon,
>>>>>> 
>>>>>>> On 12 Apr 2020, at 16:36, Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> wrote:
>>>>>>> +        except ProtocolError(e):
>>>>>> 
>>>>>> Should this not be
>>>>>> 
>>>>>>      except ProtocolError as e:
>>>>> 
>>>>> Unless there is a functional difference, does it matter?
>>>>> 
>>>>> /Jarkko
>>>> 
>>>> Well, your patch confuses me a lot. It looks to me like you are passing
>>>> the undefined `e` variable to the constructor.
>>>> 
>>>> When I run flake8 on it I get following error (among others):
>>>> 
>>>>   F821 undefined name 'e'
>>> 
>>> I don't know what flake8 is.
>> 
>> https://flake8.pycqa.org/en/latest/
>> 
>>>> What I suggested is the standard syntax:
>>>> https://docs.python.org/3/tutorial/errors.html
>>> 
>>> It passed the Python 3 interpreter.
>> 
>> That is because it is technically valid syntax.
>> 
>>>> Did you test this? You should get an error as soon as an exception
>>>> occurs.
>>> 
>>> Yes. Interpreter did not complain. I did not know that the language
>>> is broken that way that you have to exercise the code path to get
>>> a syntax error.
>> 
>> That is due to the dynamic nature of Python. You won’t get a syntax
>> error. You will get an exception:
>> 
>>    NameError: name 'e' is not defined
>> 
>> Python has to assume that `e` might be defined at runtime. However,
>> style checkers will complain.
> 
> OK, I'm aware about the dynamic nature but in this case it is somewhat
> counter intuitive since it is part of the exception clause. You'd except
> the Python interpreter to complain.
> 
> So, is Flake8 like the standard to be used?
> 
> /Jarkko





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

  Powered by Linux