Sertonix 736d1b386e community/py3-commentjson: re-add
This reverts commit af42a009dc7f10340adf66e04a7ae5817480a464.
2026-05-01 08:12:26 +00:00

40 lines
1.4 KiB
Diff

diff --git a/commentjson/commentjson.py b/commentjson/commentjson.py
index 48eebb7..11a3de4 100755
--- a/commentjson/commentjson.py
+++ b/commentjson/commentjson.py
@@ -49,7 +49,11 @@ parser = Lark('''
| /(#|\\/\\/)[^\\n]*/
TRAILING_COMMA: ","
- %import common.ESCAPED_STRING
+ _STRING_INNER: /.*?/s
+ _STRING_ESC_INNER: _STRING_INNER /(?<!\\\\)(\\\\\\\\)*?/
+
+ ESCAPED_STRING : "\\"" _STRING_ESC_INNER "\\""
+
%import common.SIGNED_NUMBER
%import common.WS
%ignore WS
diff --git a/commentjson/tests/test_json/__init__.py b/commentjson/tests/test_json/__init__.py
index e97a5ce..4543677 100644
--- a/commentjson/tests/test_json/__init__.py
+++ b/commentjson/tests/test_json/__init__.py
@@ -7,3 +7,4 @@ class CommentJsonTest(unittest.TestCase):
json = commentjson
loads = staticmethod(commentjson.loads)
dumps = staticmethod(commentjson.dumps)
+ JSONDecodeError = ValueError
diff --git a/commentjson/tests/test_json/test_decode.py b/commentjson/tests/test_json/test_decode.py
index 6971c44..199a39d 100644
--- a/commentjson/tests/test_json/test_decode.py
+++ b/commentjson/tests/test_json/test_decode.py
@@ -17,8 +17,6 @@ class TestCommentJsonDecode(TestDecode, CommentJsonTest):
def __init__(self, *args, **kwargs):
super(TestCommentJsonDecode, self).__init__(*args, **kwargs)
- self.JSONDecodeError = ValueError
-
_json = self.json
class Decoder(object):