File tree 1 file changed +11
-2
lines changed
fluent.runtime/fluent/runtime
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 40
40
class CurrentEnvironment (object ):
41
41
# The parts of ResolverEnvironment that we want to mutate (and restore)
42
42
# temporarily for some parts of a call chain.
43
+
44
+ # The values of attributes here must not be mutated, they must only be
45
+ # swapped out for different objects using `modified` (see below).
46
+
47
+ # For Messages, VariableReference nodes are interpreted as external args,
48
+ # but for Terms they are the values explicitly passed using CallExpression
49
+ # syntax. So we have to be able to change 'args' for this purpose.
43
50
args = attr .ib ()
51
+ # This controls whether we need to report an error if a VariableReference
52
+ # refers to an arg that is not present in the args dict.
44
53
error_for_missing_arg = attr .ib (default = True )
45
54
46
55
@@ -58,8 +67,8 @@ def modified(self, **replacements):
58
67
Context manager that modifies the 'current' attribute of the
59
68
environment, restoring the old data at the end.
60
69
"""
61
- # CurrentEnvironment only has immutable args at the moment , so the
62
- # shallow copy returned by attr.evolve is fine.
70
+ # CurrentEnvironment only has args that we never mutate , so the shallow
71
+ # copy returned by attr.evolve is fine (at least for now) .
63
72
old_current = self .current
64
73
self .current = attr .evolve (old_current , ** replacements )
65
74
yield self
You can’t perform that action at this time.
0 commit comments