New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mgr/dashboard: pool: fix python3 dict_keys error #21636
Conversation
@@ -15,7 +15,7 @@ class Pool(RESTController): | |||
@classmethod | |||
def _serialize_pool(cls, pool, attrs): | |||
if not attrs or not isinstance(attrs, list): | |||
attrs = pool.keys() | |||
attrs = list(pool.keys()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, pool.keys()
returns an iterator in Python 3. But attrs
is used only once in line 23. I'd think, this line should actually be OK, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks sane.
May I say that I really dislike the use of iterators in Python 3? They introduced a ton of unnecessary bugs this way. |
Signed-off-by: Ricardo Dias <rdias@suse.com>
6ec4f9b
to
f866072
Compare
@sebastian-philipp addressed your comment, and pushed changes. |
lgtm |
The value returned by
dict.keys()
in python 3 is not of typelist
and is not JSON serializable.Therefore we need to convert the result to a list.
Signed-off-by: Ricardo Dias rdias@suse.com