[Python-modules-commits] [python-pyld] 259/276: Fix context caching bug.

Wolfgang Borgert debacle at moszumanska.debian.org
Wed Oct 8 23:48:18 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch master
in repository python-pyld.

commit 79c3f26b24333d55313c9122cbd21fc732ba7fd5
Author: Dave Longley <dlongley at digitalbazaar.com>
Date:   Wed Jul 9 15:19:09 2014 -0400

    Fix context caching bug.
    
    - Update active context for each processed context to ensure
      the proper associations are made in the cache between an
      active context, the local context processed, and the result.
---
 lib/pyld/jsonld.py | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py
index 2b3f4e6..d86879e 100644
--- a/lib/pyld/jsonld.py
+++ b/lib/pyld/jsonld.py
@@ -2407,13 +2407,13 @@ class JsonLdProcessor:
         if len(ctxs) == 0:
             return self._clone_active_context(active_ctx)
 
-        # process each context in order
+        # process each context in order, update active context on each
+        # iteration to ensure proper caching
         rval = active_ctx
-        must_clone = True
         for ctx in ctxs:
             # reset to initial context
             if ctx is None:
-                rval = self._get_initial_context(options)
+                rval = active_ctx = self._get_initial_context(options)
                 must_clone = False
                 continue
 
@@ -2432,14 +2432,12 @@ class JsonLdProcessor:
             if _cache.get('activeCtx') is not None:
                 cached = _cache['activeCtx'].get(active_ctx, ctx)
                 if cached:
-                    rval = cached
-                    must_clone = True
+                    rval = active_ctx = cached
                     continue
 
-            # clone context, if required, before updating
-            if must_clone:
-                rval = self._clone_active_context(active_ctx)
-                must_clone = False
+            # update active context and clone new one before updating
+            active_ctx = rval
+            rval = self._clone_active_context(active_ctx)
 
             # define context mappings for keys in local context
             defined = {}
@@ -3756,7 +3754,7 @@ class JsonLdProcessor:
         if _is_keyword(term):
             raise JsonLdError(
                 'Invalid JSON-LD syntax; keywords cannot be overridden.',
-                'jsonld.SyntaxError', {'context': local_ctx},
+                'jsonld.SyntaxError', {'context': local_ctx, 'term': term},
                 code='keyword redefinition')
 
         if term == '':

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-pyld.git



More information about the Python-modules-commits mailing list