Skip to content

Commit

Permalink
adding str check
Browse files Browse the repository at this point in the history
  • Loading branch information
sydney-runkle committed Apr 12, 2024
1 parent 1b84773 commit c1d585f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pydantic/aliases.py
Expand Up @@ -42,6 +42,9 @@ def search_dict_for_path(self, d: dict) -> Any:
"""
v = d
for k in self.path:
if isinstance(v, str):
# disallow indexing into a str, like for AliasPath('x', 0) and x='abc'
return PydanticUndefined
try:
v = v[k]
except (KeyError, IndexError, TypeError):
Expand Down

0 comments on commit c1d585f

Please sign in to comment.