Skip to content

Commit

Permalink
Fix ast parsing in old versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
baterflyrity committed Dec 7, 2023
1 parent 5be8788 commit 4d7d420
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/json_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ def _handle_nan(x):
@_rule('STRING')
def _handle_string(x: str):
assert x.startswith(('"', "'")) and x.endswith(('"', "'")), f'Unterminated string: {x}'
return ast.parse(f'"""{x[1:-1]}"""').body[0].value.value
obj = ast.parse(f'"""{x[1:-1]}"""').body[0].value
try:
return obj.value
except AttributeError:
return obj.s


@lru_cache()
Expand Down

0 comments on commit 4d7d420

Please sign in to comment.