From 15f60540096502677febba37805926b937706640 Mon Sep 17 00:00:00 2001 From: Patrick St-Louis Date: Tue, 30 Jan 2024 13:19:06 -0500 Subject: [PATCH 1/2] change 2 if statements Signed-off-by: Patrick St-Louis --- lib/pyld/context_resolver.py | 2 +- lib/pyld/jsonld.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pyld/context_resolver.py b/lib/pyld/context_resolver.py index d670b083..9f96910e 100644 --- a/lib/pyld/context_resolver.py +++ b/lib/pyld/context_resolver.py @@ -63,7 +63,7 @@ def resolve(self, active_ctx, context, base, cycles=None): all_resolved.extend(resolved) else: all_resolved.append(resolved) - elif not ctx: + elif ctx is None: all_resolved.append(ResolvedContext(False)) elif not isinstance(ctx, dict) and not isinstance(ctx, frozendict): raise jsonld.JsonLdError( diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py index 49d62122..b63d0df8 100644 --- a/lib/pyld/jsonld.py +++ b/lib/pyld/jsonld.py @@ -2320,7 +2320,7 @@ def _expand( for type_ in sorted(types): ctx = JsonLdProcessor.get_context_value( type_scoped_ctx, type_, '@context') - if ctx is not None: + if ctx: active_ctx = self._process_context( active_ctx, ctx, options, propagate=False) @@ -3070,7 +3070,7 @@ def _process_context(self, active_ctx, local_ctx, options, active_ctx['_uuid'] = str(uuid.uuid1()) # reset to initial context - if not ctx: + if ctx is None: if (not override_protected and any(v.get('protected') for v in rval['mappings'].values())): raise JsonLdError( From 5fab002359b26475d2f34c078d248a7eb5ad2097 Mon Sep 17 00:00:00 2001 From: pstlouis Date: Wed, 31 Jan 2024 17:28:51 -0500 Subject: [PATCH 2/2] include both False and None values in condition checks Signed-off-by: pstlouis --- lib/pyld/context_resolver.py | 2 +- lib/pyld/jsonld.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pyld/context_resolver.py b/lib/pyld/context_resolver.py index 9f96910e..6714cbbf 100644 --- a/lib/pyld/context_resolver.py +++ b/lib/pyld/context_resolver.py @@ -63,7 +63,7 @@ def resolve(self, active_ctx, context, base, cycles=None): all_resolved.extend(resolved) else: all_resolved.append(resolved) - elif ctx is None: + elif ctx is None or ctx is False: all_resolved.append(ResolvedContext(False)) elif not isinstance(ctx, dict) and not isinstance(ctx, frozendict): raise jsonld.JsonLdError( diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py index b63d0df8..5266a89b 100644 --- a/lib/pyld/jsonld.py +++ b/lib/pyld/jsonld.py @@ -2320,7 +2320,7 @@ def _expand( for type_ in sorted(types): ctx = JsonLdProcessor.get_context_value( type_scoped_ctx, type_, '@context') - if ctx: + if ctx is not None and ctx is not False: active_ctx = self._process_context( active_ctx, ctx, options, propagate=False) @@ -3070,7 +3070,7 @@ def _process_context(self, active_ctx, local_ctx, options, active_ctx['_uuid'] = str(uuid.uuid1()) # reset to initial context - if ctx is None: + if ctx is None or ctx is False: if (not override_protected and any(v.get('protected') for v in rval['mappings'].values())): raise JsonLdError(