[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 19/25] qapi: Improve reporting of invalid flags
From: |
Markus Armbruster |
Subject: |
Re: [PATCH 19/25] qapi: Improve reporting of invalid flags |
Date: |
Wed, 25 Sep 2019 08:13:10 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Markus Armbruster <address@hidden> writes:
> Eric Blake <address@hidden> writes:
>
>> On 9/24/19 8:28 AM, Markus Armbruster wrote:
>>> Split check_flags() off check_keys() and have check_exprs() call it
>>> later, so its error messages gain an "in definition" line. Tweak the
>>> error messages.
>>>
>>> Checking values in a function named check_keys() is unclean anyway.
>>>
>>> Signed-off-by: Markus Armbruster <address@hidden>
>>> ---
>>> scripts/qapi/common.py | 22 ++++++++++++----------
>>> tests/qapi-schema/allow-preconfig-test.err | 3 ++-
>>> tests/qapi-schema/args-bad-boxed.err | 3 ++-
>>> tests/qapi-schema/oob-test.err | 3 ++-
>>> tests/qapi-schema/type-bypass-bad-gen.err | 3 ++-
>>> 5 files changed, 20 insertions(+), 14 deletions(-)
>>>
>>
>>> +
>>> +def check_flags(expr, info):
>>> + for key in ['gen', 'success-response']:
>>> + if key in expr and expr[key] is not False:
>>
>> Is it any more pythonic and/or a micro-optimization to compress this to:
>>
>> if expr.get(key, False) is not False:
>>
>>> + raise QAPISemError(
>>> + info, "flag '%s' may only use false value" % key)
>>> + for key in ['boxed', 'allow-oob', 'allow-preconfig']:
>>> + if key in expr and expr[key] is not True:
>>
>> and here too.
>
> Will do.
Second thoughts in the morning:
if key in expr and expr[key] is not VALUE:
feels slightly clearer than
if expr.get(key, VALUE) is not VALUE:
>> Reviewed-by: Eric Blake <address@hidden>
>
> Thanks!