[Checkins] SVN: z3c.pt/trunk/ Fixed bug where a repeat-clause would reset the repeat variable
Malthe Borch
mborch at gmail.com
Tue Sep 9 12:08:11 EDT 2008
Log message for revision 91006:
Fixed bug where a repeat-clause would reset the repeat variable
before evaluating the expression.
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/clauses.py
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2008-09-09 16:06:27 UTC (rev 91005)
+++ z3c.pt/trunk/CHANGES.txt 2008-09-09 16:08:09 UTC (rev 91006)
@@ -169,6 +169,9 @@
Bugfixes
+- Fixed bug where a repeat-clause would reset the repeat variable
+ before evaluating the expression. [malthe]
+
- Fixed an issue related to correct restoring of ghosted template
objects. [malthe]
Modified: z3c.pt/trunk/src/z3c/pt/clauses.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/clauses.py 2008-09-09 16:06:27 UTC (rev 91005)
+++ z3c.pt/trunk/src/z3c/pt/clauses.py 2008-09-09 16:08:09 UTC (rev 91006)
@@ -248,8 +248,10 @@
>>> a
1
"""
+
+ assign = None
- def __init__(self, declaration, expression, dictionary=None):
+ def __init__(self, declaration, expression=None, dictionary=None):
if not isinstance(declaration, types.declaration):
declaration = types.declaration((declaration,))
@@ -260,8 +262,10 @@
if dictionary is not None:
variable = "%s['%s'] = %s" % (dictionary, variable, variable)
+
+ if expression is not None:
+ self.assign = Assign(expression, variable)
- self.assign = Assign(expression, variable)
self.declaration = declaration
self.dictionary = dictionary
@@ -288,11 +292,13 @@
stream.write('%s = %s' % (temp, var))
stream.scope[-1].add(var)
-
- self.assign.begin(stream)
+ if self.assign is not None:
+ self.assign.begin(stream)
+
def end(self, stream):
- self.assign.end(stream)
+ if self.assign is not None:
+ self.assign.end(stream)
if not self.declaration.global_scope:
# restore the variables that were previously in scope
@@ -673,7 +679,7 @@
def __init__(self, v, e, scope=(), repeatdict=True):
self.variable = v
self.expression = e
- self.define = Define(v, types.value("None"))
+ self.define = Define(v)
self.assign = Assign(e)
self.repeatdict = repeatdict
@@ -695,6 +701,7 @@
# loop
stream.write("try:")
stream.indent()
+ stream.write("%s = None" % variable)
stream.write("%s = %s.next()" % (variable, iterator))
stream.write("while True:")
stream.indent()
More information about the Checkins
mailing list