[PATCH v4 30/46] qapi/gen.py: Fix edge-case of _is_user_module

John Snow posted 46 patches 5 years, 4 months ago
Maintainers: "Dr. David Alan Gilbert" <dgilbert@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Juan Quintela <quintela@redhat.com>, Eric Blake <eblake@redhat.com>, Thomas Huth <thuth@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Markus Armbruster <armbru@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Cleber Rosa <crosa@redhat.com>, Michael Roth <mdroth@linux.vnet.ibm.com>
There is a newer version of this series
[PATCH v4 30/46] qapi/gen.py: Fix edge-case of _is_user_module
Posted by John Snow 5 years, 4 months ago
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>
Reviewed-by: Cleber Rosa <crosa@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 b8a6fe8a5c3..58cc1d8e734 100644
--- a/scripts/qapi/gen.py
+++ b/scripts/qapi/gen.py
@@ -243,7 +243,7 @@ def __init__(self, prefix, what, user_blurb, builtin_blurb, pydoc):
 
     @staticmethod
     def _is_user_module(name):
-        return name and not name.startswith('./')
+        return bool(name and not name.startswith('./'))
 
     @staticmethod
     def _is_builtin_module(name):
-- 
2.26.2


Re: [PATCH v4 30/46] qapi/gen.py: Fix edge-case of _is_user_module
Posted by Eduardo Habkost 5 years, 4 months ago
On Wed, Sep 30, 2020 at 12:31:34AM -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>
> Reviewed-by: Cleber Rosa <crosa@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

-- 
Eduardo