From 0dd6b20b2ff54e1b3bf15957fab77193c287fbea Mon Sep 17 00:00:00 2001 From: yenatch Date: Sat, 1 Nov 2014 20:42:41 -0700 Subject: BSSReader: Fix eval inserting __builtins__ into self.constants. Eval should really not be used in the first place, but at least it works again. Fixes 82b78e5c7969aebb797f35a58577dd0afb2c2f38, which replaced the constants_to_dict method with BSSReader. --- pokemontools/wram.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pokemontools/wram.py b/pokemontools/wram.py index e25ca37..b6d7fc6 100644 --- a/pokemontools/wram.py +++ b/pokemontools/wram.py @@ -58,7 +58,7 @@ class BSSReader: if token in ['ds', 'db', 'dw']: if any(params): - length = eval(rgbasm_to_py(params[0]), self.constants) + length = eval(rgbasm_to_py(params[0]), self.constants.copy()) else: length = {'ds': 1, 'db': 1, 'dw': 2}[token] self.address += length @@ -172,7 +172,7 @@ class BSSReader: real = split_line[index] name, value = map(' '.join, [split_line[:index], split_line[index+1:]]) value = rgbasm_to_py(value) - self.constants[name] = eval(value, self.constants) + self.constants[name] = eval(value, self.constants.copy()) else: self.read_bss_line(line) @@ -195,7 +195,7 @@ def scrape_constants(text): bss = BSSReader() bss.read_bss_sections(text) constants = bss.constants - return constants + return {v: k for k, v in constants.items()} def read_constants(filepath): """ -- cgit v1.2.3