From 052555ec71510f514ee775c901fa83a6f0a9dce2 Mon Sep 17 00:00:00 2001 From: Tim Vieira Date: Thu, 18 Jul 2013 13:21:54 -0400 Subject: [PATCH] Fixed issue #52. --- run-doctests.py | 4 ++-- src/Dyna/Backend/Python/interpreter.py | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/run-doctests.py b/run-doctests.py index 32ecb74..18b5a85 100755 --- a/run-doctests.py +++ b/run-doctests.py @@ -19,7 +19,7 @@ failures = [] print 'End-to-end' print '==========' -for z in path('examples/expected').glob("*.py.out"): +for z in sorted(path('examples/expected').glob("*.py.out")): x = re.sub('(examples/)expected/(.*).py.out', r'\1\2.dyna', z) y = x + '.py.out' @@ -47,7 +47,7 @@ print print 'Doctests' print '========' -for x in path('test').glob("*/*.dynadoc"): +for x in sorted(path('test').glob("*/*.dynadoc")): print x, sys.stdout.flush() with file(x) as f: diff --git a/src/Dyna/Backend/Python/interpreter.py b/src/Dyna/Backend/Python/interpreter.py index e8bac8a..c97fa46 100644 --- a/src/Dyna/Backend/Python/interpreter.py +++ b/src/Dyna/Backend/Python/interpreter.py @@ -139,6 +139,11 @@ class Interpreter(object): if was == now: # nothing to do. return + # special handling for with_key, forks a second update + self.replace(self.build('$key/1', item), None) # always clear $key + if hasattr(now, 'fn') and now.fn == 'with_key/2': + now, key = now.args + self.replace(self.build('$key/1', item), key) # delete existing value before so we can replace it if was is not None: self.push(item, was, delete=True) @@ -188,13 +193,6 @@ class Interpreter(object): self.set_error(item, (None, [(e, None)])) else: - # issue replacement update - - # special handling for with_key, forks into two updates - if hasattr(now, 'fn') and now.fn == 'with_key/2': - now, key = now.args - self.replace(self.build('$key/1', item), key) - self.replace(item, now) return now -- 2.50.1