[Checkins] SVN: Sandbox/malthe/chameleon.core/ Fixed bug where multiple defines would cause integrity issues.

Malthe Borch mborch at gmail.com
Mon Nov 17 19:41:43 EST 2008


Log message for revision 93066:
  Fixed bug where multiple defines would cause integrity issues.

Changed:
  U   Sandbox/malthe/chameleon.core/CHANGES.txt
  U   Sandbox/malthe/chameleon.core/src/chameleon/core/clauses.py

-=-
Modified: Sandbox/malthe/chameleon.core/CHANGES.txt
===================================================================
--- Sandbox/malthe/chameleon.core/CHANGES.txt	2008-11-17 23:20:53 UTC (rev 93065)
+++ Sandbox/malthe/chameleon.core/CHANGES.txt	2008-11-18 00:41:43 UTC (rev 93066)
@@ -4,6 +4,9 @@
 HEAD
 ~~~~
 
+- Fixed issue where multiple defines would cause integrity
+  issues. [malthe]
+
 - Avoid self-closing tags that are not allowed in transitional
   HTML. [malthe]
 

Modified: Sandbox/malthe/chameleon.core/src/chameleon/core/clauses.py
===================================================================
--- Sandbox/malthe/chameleon.core/src/chameleon/core/clauses.py	2008-11-17 23:20:53 UTC (rev 93065)
+++ Sandbox/malthe/chameleon.core/src/chameleon/core/clauses.py	2008-11-18 00:41:43 UTC (rev 93066)
@@ -291,16 +291,17 @@
         else:
             # save local variables already in in scope
             for var in self.declaration:
-                temp = stream.save()
-
-                # If we didn't set the variable in this scope already
+                
+                # if we didn't set the variable in this scope already
                 if var not in stream.scope[-1]:
 
-                    # we'll check if it's set in one of the older scopes
+                    # we'll check if it's set in one of the older
+                    # scopes, e.g. if a backup is at all required
                     for scope in stream.scope[:-1]:
                         if var in scope:
-                            # in which case we back it up
-                            stream.write('%s = %s' % (temp, var))
+                            # in which case we back it up to a custom variable name
+                            stream.write('%s = %s' % (
+                                stream.symbols.tmp+var, var))
 
                     stream.scope[-1].add(var)
 
@@ -314,15 +315,14 @@
         if not self.declaration.global_scope:
             # restore the variables that were previously in scope
             for var in reversed(self.declaration):
-                temp = stream.restore()
-
                 # if we set the variable in this scope already
                 if var in stream.scope[-1]:
                     # we'll check if it's set in one of the older scopes
                     for scope in stream.scope[:-1]:
                         if var in scope:
                             # in which case we restore it
-                            stream.write('%s = %s' % (var, temp))
+                            stream.write('%s = %s' % (
+                                var, stream.symbols.tmp+var))
                             break
                     else:
                         stream.write("del %s" % var)
@@ -898,7 +898,7 @@
             stream.symbol_mapping[stream.symbols.validate] = etree.validate
             write("%(validate)s(%(tmp)s)")
 
-        if self.assign:
+        if not value:
             self.assign.end(stream)
         stream.restore()
 



More information about the Checkins mailing list