Skip to content
Open
Changes from all commits
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
11 changes: 10 additions & 1 deletion glom/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,16 @@ def __subclasshook__(cls, C):


def _get_sequence_item(target, index):
return target[int(index)]
try:
return target[int(index)]
except ValueError as e:
if 'invalid literal for int() with base 10:' in str(e):
msg = ("Error indexing the target. This can happen when your "
"target is a list and your spec is not. Did you forget "
"to put brackets around your spec?")
raise ValueError(msg)
else:
raise e


# handlers are 3-arg callables, with args (spec, target, scope)
Expand Down