gcode_macro: fix reference issues to the variables attribute (#4925)

Create a copy of the dictionary prior to updating the the variable field.
This fixes an issue where webhooks holds a reference to the variables
dict returned by get_status().

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2021-11-19 02:01:16 -05:00 committed by GitHub
parent 68c92991ed
commit 46381e03a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -171,7 +171,9 @@ class GCodeMacro:
literal = ast.literal_eval(value)
except ValueError as e:
raise gcmd.error("Unable to parse '%s' as a literal" % (value,))
self.variables[variable] = literal
v = dict(self.variables)
v[variable] = literal
self.variables = v
def cmd(self, gcmd):
if self.in_script:
raise gcmd.error("Macro %s called recursively" % (self.alias,))