summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2014-11-01 20:42:41 -0700
committeryenatch <yenatch@gmail.com>2014-11-01 20:42:41 -0700
commit0dd6b20b2ff54e1b3bf15957fab77193c287fbea (patch)
tree0835b54f49ad2ccf7e5b795a5ed70f2c8d5da5e2
parent85e0e2af68301288f394631196a8dc5af10eab27 (diff)
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.
-rw-r--r--pokemontools/wram.py6
1 files 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):
"""