Skip to content

Fix paths for bytes dictionary keys - #640

Open
x0Lazarus wants to merge 1 commit into
qlustered:devfrom
x0Lazarus:fix/bytes-dictionary-paths
Open

x0Lazarus wants to merge 1 commit into
qlustered:devfrom
x0Lazarus:fix/bytes-dictionary-paths

Conversation

@x0Lazarus

Copy link
Copy Markdown

DeepDiff({b"foo": 1}, {b"foo": 2}) raises TypeError while building the path for the changed value. The original example in #472 can appear to work now because the default dictionary threshold reports the whole dictionary as changed; comparing values under the same bytes key still reaches the broken path handling.

This reports the change at root[b'foo'] and keeps the resulting paths usable by parse_path, extract, and Delta. Bytes keys are written as Python bytes literals, and the parser handles their escaped quotes and backslashes. The regression cases cover nested additions, removals, and value changes with empty keys, both quote types, trailing backslashes, and non-ASCII bytes, including forward and reverse Delta application.

This builds on the bytes-literal approach proposed by Mukller in #614, with the parsing changes needed to make escaped keys round-trip. Memoryview behavior is unchanged.

Validation on Windows with Python 3.12.14:

  • Path and model suites: 79 passed. The 33 new bytes-key cases fail against unchanged dev.
  • Broader suite, with security-specific tests excluded: 1,342 passed, 8 skipped, 2 deselected, and one existing failure in test_delta_dump_and_read3. The same Windows text-mode pickle failure reproduces on unchanged dev.
  • Targeted Pyright and the blocking flake8 checks pass. Six existing style findings are unchanged. Other Python versions and Linux were not tested locally.

Fixes #472.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant