From 4d7d420063be6954ebe7919a70c699dcb992ae10 Mon Sep 17 00:00:00 2001 From: baterflyrity Date: Thu, 7 Dec 2023 20:35:24 +0300 Subject: [PATCH] Fix ast parsing in old versions. --- tests/json_parser/parser.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/json_parser/parser.py b/tests/json_parser/parser.py index 31679fc..c26ed83 100644 --- a/tests/json_parser/parser.py +++ b/tests/json_parser/parser.py @@ -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()