-
-
Notifications
You must be signed in to change notification settings - Fork 396
Cast dict_values To A list
#243
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
Conversation
minrk
left a comment
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.
Thanks! I left a comment about how to test for dict_values.
How did you come across this? It's likely that hitting this means that code elsewhere should change, because dict_values views probably shouldn't be passed to messages at this level.
ipykernel/jsonutil.py
Outdated
| out = {} | ||
| for k,v in iteritems(obj): | ||
| out[unicode_type(k)] = json_clean(v) | ||
| if str(type(v)) == "<class 'dict_values'>": |
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.
dict_values can be checked for with:
if PY3:
from collections.abc import MappingView
...
if PY3 and isinstance(obj, MappingView):
obj = list(obj)and this should be at the top level, not inside the dict case.
I am currently trying to get GeoNotebook running on Python 3; I encountered it there. If there is something that I can do to help detect similar issues I am happy to do so (but as you no-doubt observed, my Python skills are a bit limited). |
|
I have attempted to update according to your comment, I hope that I interpreted it correctly. |
|
Should I close this PR? |
|
Sorry it fell under our radar. Appologies, we'll re-have a look. |
|
Ah, okay, many thanks. |
This resolves the following issue that I observed on Python 3:
I am willing to make any changes that might be requested/required.