Whole file
sean2077/jsonpath-python
The author described this change as “fix: resolve issue #17 false positive errors and parsing bugs”. It counts as a record because the check below fails on the code as it stood at 18eab0b6f and passes on 47bba2512, with nothing else changed between the two runs.
Projectsean2077/jsonpath-python
Fix saved2025-11-23
Sharing licenceMIT · LICENSE
Change size+4 −3
What the code was meant to do, written into the code itself as a save note
fix: resolve issue #17 false positive errors and parsing bugs
The change
| 66 | 66 | ||
| 67 | 67 | def __init__(self, expr: str): | |
| 68 | 68 | expr = self._parse_expr(expr) | |
| 69 | - | self.segments = expr.split(JSONPath.SEP) | |
| 69 | + | self.segments = [s for s in expr.split(JSONPath.SEP) if s] | |
| 70 | 70 | self.lpath = len(self.segments) | |
| 71 | 71 | logger.debug(f"segments : {self.segments}") | |
| 72 | 72 | ||
| ⋯ | |||
| 95 | 95 | expr = JSONPath.REP_GET_QUOTE.sub(self._get_quote, expr) | |
| 96 | 96 | expr = JSONPath.REP_GET_BACKQUOTE.sub(self._get_backquote, expr) | |
| 97 | 97 | expr = JSONPath.REP_GET_BRACKET.sub(self._get_bracket, expr) | |
| 98 | + | expr = re.sub(r"\.(\.#B)", r"\1", expr) | |
| 98 | 99 | expr = JSONPath.REP_GET_PAREN.sub(self._get_paren, expr) | |
| 99 | 100 | # split | |
| 100 | 101 | expr = JSONPath.REP_DOUBLEDOT.sub(f"{JSONPath.SEP}..{JSONPath.SEP}", expr) | |
| ⋯ | |||
| 195 | 196 | r = False | |
| 196 | 197 | try: | |
| 197 | 198 | r = self.eval_func(step, None, {"__obj": obj}) | |
| 198 | - | except Exception as err: | |
| 199 | - | logger.error(err) | |
| 199 | + | except Exception: | |
| 200 | + | pass | |
| 200 | 201 | if r: | |
| 201 | 202 | self._trace(obj, i, path) | |
| 202 | 203 | ||
The check that tells the two apart
fail→pass·tests/test_issues.py::test_issue_17_bracket_dot_normalization
Check file tests/test_issues.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it18eab0b6f4e3b5e36c307786104edb14aeeecf54
Broken version dated2025-11-23
Modulejsonpath.jsonpath
Units changedJSONPath
Fingerprinte42421b0b5c12945
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.