Repository: h2non/jsonpath-ng (language: python)

Issue:
Deprecation warning due to invalid escape sequences in Python 3.8
Deprecation warnings are raised due to invalid escape sequences in Python 3.8 . Below is a log of the warnings raised during compiling all the python files. Using raw strings or escaping them will fix this issue.

```
find . -iname '*.py'  | xargs -P 4 -I{} python -Walways -m py_compile {}

./jsonpath_ng/ext/string.py:18: DeprecationWarning: invalid escape sequence \(
  SUB = re.compile("sub\(/(.*)/,\s+(.*)\)")
./jsonpath_ng/ext/string.py:19: DeprecationWarning: invalid escape sequence \(
  SPLIT = re.compile("split\((.),\s+(\d+),\s+(\d+|-1)\)")
./tests/test_jsonpath_rw_ext.py:129: DeprecationWarning: invalid escape sequence \c
  ('sort2', dict(string='objects[\cat]',
./tests/test_jsonpath_rw_ext.py:132: DeprecationWarning: invalid escape sequence \c
  ('sort2_indexed', dict(string='objects[\cat][-1].cat',
./tests/test_jsonpath_rw_ext.py:136: DeprecationWarning: invalid escape sequence \c
  ('sort3', dict(string='objects[/cow,\cat]',
./tests/test_jsonpath_rw_ext.py:145: DeprecationWarning: invalid escape sequence \c
  ('sort3_indexed', dict(string='objects[/cow,\cat][0].cat',
```


Discussion / hints:

Fix patch:
diff --git a/jsonpath_ng/ext/string.py b/jsonpath_ng/ext/string.py
index 80ed890..1cd2763 100644
--- a/jsonpath_ng/ext/string.py
+++ b/jsonpath_ng/ext/string.py
@@ -15,9 +15,9 @@
 from .. import DatumInContext, This
 
 
-SUB = re.compile("sub\(/(.*)/,\s+(.*)\)")
-SPLIT = re.compile("split\((.),\s+(\d+),\s+(\d+|-1)\)")
-STR = re.compile("str\(\)")
+SUB = re.compile(r"sub\(/(.*)/,\s+(.*)\)")
+SPLIT = re.compile(r"split\((.),\s+(\d+),\s+(\d+|-1)\)")
+STR = re.compile(r"str\(\)")
 
 
 class DefintionInvalid(Exception):


Test patch:
diff --git a/tests/test_jsonpath_rw_ext.py b/tests/test_jsonpath_rw_ext.py
index 163e1be..8b80ec2 100644
--- a/tests/test_jsonpath_rw_ext.py
+++ b/tests/test_jsonpath_rw_ext.py
@@ -126,14 +126,14 @@ class Testjsonpath_ng_ext(testscenarios.WithScenarios,
                                                  {'cat': 2, 'cow': 1},
                                                  {'cat': 3, 'cow': 3}]},
                                target=2)),
-        ('sort2', dict(string='objects[\cat]',
+        ('sort2', dict(string='objects[\\cat]',
                        data={'objects': [{'cat': 2}, {'cat': 1}, {'cat': 3}]},
                        target=[[{'cat': 3}, {'cat': 2}, {'cat': 1}]])),
-        ('sort2_indexed', dict(string='objects[\cat][-1].cat',
+        ('sort2_indexed', dict(string='objects[\\cat][-1].cat',
                                data={'objects': [{'cat': 2}, {'cat': 1},
                                                  {'cat': 3}]},
                                target=1)),
-        ('sort3', dict(string='objects[/cow,\cat]',
+        ('sort3', dict(string='objects[/cow,\\cat]',
                        data={'objects': [{'cat': 1, 'cow': 2},
                                          {'cat': 2, 'cow': 1},
                                          {'cat': 3, 'cow': 1},
@@ -142,7 +142,7 @@ class Testjsonpath_ng_ext(testscenarios.WithScenarios,
                                {'cat': 2, 'cow': 1},
                                {'cat': 1, 'cow': 2},
                                {'cat': 3, 'cow': 3}]])),
-        ('sort3_indexed', dict(string='objects[/cow,\cat][0].cat',
+        ('sort3_indexed', dict(string='objects[/cow,\\cat][0].cat',
                                data={'objects': [{'cat': 1, 'cow': 2},
                                                  {'cat': 2, 'cow': 1},
                                                  {'cat': 3, 'cow': 1},