Recently I found out that Python dict and set comprehensions used within .rpy scripts do not produce RevertableDict and RevertableSet objects. In contrast to this behavior list comprehensions create instances of RevertableList.
Personally I would prefer if all kinds of comprehensions will produce "revertable objects". It seems to be more consistent approach as well.
So, is this intentional difference between list and set/dict comprehensions?
EDIT:
For now, by analogy with existent wrappers I've added two methods into WrapNode class (renpy/python.py, line 329):
Code: Select all
def visit_DictComp(self, n):
return ast.Call(
func = ast.Name(
id="__renpy__dict__",
ctx=ast.Load()
),
args = [ self.generic_visit(n) ],
keywords = [ ],
starargs = None,
kwargs = None)
def visit_SetComp(self, n):
return ast.Call(
func = ast.Name(
id="set",
ctx=ast.Load()
),
args = [ self.generic_visit(n) ],
keywords = [ ],
starargs = None,
kwargs = None)