Conversation
- _replace_jsonld_context_mapping deep-copies a dict argument at entry - values of an unhandled type are returned unchanged instead of None - add unit tests covering dicts, lists, scoped contexts and copy depth Closes #177
Contributor
Release previewMerging this PR would release v2.3.4 (current: Changelog preview (truncated)## v2.3.4 (2026-09-18)
### Bug Fixes
- **wtsite**: Copy the jsonld context before rewriting it
([`ea0cddf`](https://github.com/OpenSemanticLab/osw-python/commit/ea0cddfa85a0025560dda49f78ff99577a86f526))
### Chores
- Relicense to Apache-2.0 ([#173](https://github.com/OpenSemanticLab/osw-python/pull/173),
[`848615c`](https://github.com/OpenSemanticLab/osw-python/commit/848615cbd1e06401922eda88231a51028440a242))
Preview via python-semantic-release and conventional commits. |
simontaurus
self-requested a review
September 18, 2026 09:46
simontaurus
approved these changes
Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #177.
Changes
WtSite._replace_jsonld_context_mappingdeep-copies adictargument atentry and rewrites the copy. The caller's object is no longer modified.
dictbranch is no longer nested in anif. An argument of anunhandled type returns unchanged instead of falling through to an implicit
None.tests/test_wtsite_jsonld_context_mapping.py.Rationale
string, a new list, the same mutated dict, or
None. The new list was ashallow copy of the caller's dictionaries, which were rewritten in place, so
it gave no protection.
deepcopyrather thandict(context): the replaced values are nesteddictionaries such as
{"@id": ..., "@type": "@id"}and scoped@contextblocks. A shallow copy repeats the defect one level down.
get_jsonld_context_loader, was safe byaccident.
WtPage.get_slot_contentreturns a fresh deepcopy on every call,so the loader rewrote a throwaway object. Nothing documented or tested that
dependency.
instance), so the copy is not a performance concern.
Verification
src/osw/wtsite.py, confirming theyguard the reported behaviour. The 2 that pass assert the rewriting rules,
which are unchanged.