[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 24/38] qapi/gen.py: Fix edge-case of _is_user_module
From: |
Cleber Rosa |
Subject: |
Re: [PATCH v2 24/38] qapi/gen.py: Fix edge-case of _is_user_module |
Date: |
Wed, 23 Sep 2020 19:08:46 -0400 |
On Tue, Sep 22, 2020 at 05:00:47PM -0400, John Snow wrote:
> The edge case is that if the name is '', this expression returns a
> string instead of a bool, which violates our declared type.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
> scripts/qapi/gen.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py
> index 9898d513ae..cb2b2655c3 100644
> --- a/scripts/qapi/gen.py
> +++ b/scripts/qapi/gen.py
> @@ -251,7 +251,7 @@ def __init__(self, prefix, what, user_blurb,
> builtin_blurb, pydoc):
>
> @staticmethod
> def _is_user_module(name):
> - return name and not name.startswith('./')
> + return name is not None and not name.startswith('./')
Another possibility here that handles the empty string situation and
will never return anything but a bool:
return all([name, not name.startswith('./')])
Either way,
Reviewed-by: Cleber Rosa <crosa@redhat.com>
signature.asc
Description: PGP signature
Re: [PATCH v2 24/38] qapi/gen.py: Fix edge-case of _is_user_module,
Cleber Rosa <=
[PATCH v2 30/38] qapi/introspect.py: Add a typed 'extra' structure, John Snow, 2020/09/22
[PATCH v2 37/38] qapi/visit.py: remove unused parameters from gen_visit_object, John Snow, 2020/09/22
[PATCH v2 36/38] qapi/visit.py: assert tag_member contains a QAPISchemaEnumType, John Snow, 2020/09/22