Skip to content

Commit

Permalink
fix(json): Fix crash caused by empty objects
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeSavefrogs committed Oct 4, 2023
1 parent 102981a commit 7b857fd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/polyfills/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ def loads(
elif char in ["}", "]"]:
last_bracket = nesting_levels.pop()

# Support for empty objects
if len(last_key) == 0 and len(nesting_levels) == 0:
result = {}
continue

if len(last_key) != 2:
raise Exception("Unexpected key tuple length: %s" % str(last_key))

Expand Down

0 comments on commit 7b857fd

Please sign in to comment.