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.

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

6666
6767 def __init__(self, expr: str):
6868 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]
7070 self.lpath = len(self.segments)
7171 logger.debug(f"segments : {self.segments}")
7272
9595 expr = JSONPath.REP_GET_QUOTE.sub(self._get_quote, expr)
9696 expr = JSONPath.REP_GET_BACKQUOTE.sub(self._get_backquote, expr)
9797 expr = JSONPath.REP_GET_BRACKET.sub(self._get_bracket, expr)
98+ expr = re.sub(r"\.(\.#B)", r"\1", expr)
9899 expr = JSONPath.REP_GET_PAREN.sub(self._get_paren, expr)
99100 # split
100101 expr = JSONPath.REP_DOUBLEDOT.sub(f"{JSONPath.SEP}..{JSONPath.SEP}", expr)
195196 r = False
196197 try:
197198 r = self.eval_func(step, None, {"__obj": obj})
198- except Exception as err:
199- logger.error(err)
199+ except Exception:
200+ pass
200201 if r:
201202 self._trace(obj, i, path)
202203

The check that tells the two apart

failpass·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.

Other bugs found in sean2077/jsonpath-python