mirror of
https://github.com/pret/pokemon-reverse-engineering-tools.git
synced 2026-09-07 01:35:12 -05:00
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 82b78e5c79, which replaced the constants_to_dict method with BSSReader.
This commit is contained in:
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user