From: Ezra Buehler <ezra@easyb.ch>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, linux-integrity@vger.kernel.org,
Tadeusz Struk <tadeusz.struk@intel.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] selftests/tpm2: Change exception handling to be Python 3 compatible
Date: Tue, 14 Apr 2020 13:14:11 +0200 [thread overview]
Message-ID: <3DDD1D36-9FCC-480A-978F-3BD08283DA03@easyb.ch> (raw)
In-Reply-To: <20200414073806.GE8403@linux.intel.com>
On 14 Apr 2020, at 09:38, Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> 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@linux.intel.com> 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@linux.intel.com> 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@linux.intel.com> 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@linux.intel.com> 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
next prev parent reply other threads:[~2020-04-14 11:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-12 14:36 Jarkko Sakkinen
2020-04-12 15:02 ` Ezra Buehler
2020-04-12 17:07 ` Jarkko Sakkinen
2020-04-13 5:02 ` Ezra Buehler
2020-04-13 18:04 ` Jarkko Sakkinen
2020-04-14 5:45 ` Ezra Buehler
2020-04-14 7:38 ` Jarkko Sakkinen
2020-04-14 11:14 ` Ezra Buehler [this message]
2020-04-14 16:05 ` Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3DDD1D36-9FCC-480A-978F-3BD08283DA03@easyb.ch \
--to=ezra@easyb.ch \
--cc=jarkko.sakkinen@linux.intel.com \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=tadeusz.struk@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®