Skip to content
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

Handle non-subscriptable path in humanize_error #206

Merged
merged 2 commits into from
Sep 22, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions voluptuous/humanize.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def _nested_getitem(data, path):
except (KeyError, IndexError):
# The index is not present in the dictionary, list or other indexable
return None
except TypeError: # data is not subscriptable
break
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kellerza Shouldn't it return None instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The advantage of resolving until you hit a failure (by breaking out) is that it helps you in the correct direction.

Happy to comply either way, your call

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it consistent with KeyError and IndexError. You can add it in Line 12 and update the comment correspondingly.

return data


Expand Down