Don't use eval() in read_bss_sections #37

Open
opened 2013-09-24 15:50:31 +00:00 by kanzure · 0 comments
kanzure commented 2013-09-24 15:50:31 +00:00 (Migrated from github.com)
kanzure@deathfortress:~/code/pokecrystal$ python extras/pokemontools/gbz80disasm.py 0x45f
Traceback (most recent call last):
  File "extras/pokemontools/gbz80disasm.py", line 934, in <module>
    disasm.initialize()
  File "extras/pokemontools/gbz80disasm.py", line 619, in initialize
    self.wram.initialize()
  File "/home/kanzure/code/pokecrystal/extras/pokemontools/wram.py", line 106, in initialize
    self.setup_wram_sections()
  File "/home/kanzure/code/pokecrystal/extras/pokemontools/wram.py", line 128, in setup_wram_sections
    self.wram_sections = self.read_wram_sections()
  File "/home/kanzure/code/pokecrystal/extras/pokemontools/wram.py", line 121, in read_wram_sections
    wram_sections = read_bss_sections(wram_content)
  File "/home/kanzure/code/pokecrystal/extras/pokemontools/wram.py", line 48, in read_bss_sections
    length = eval(line[3:line.find(';')].replace('$','0x'))
  File "<string>", line 1, in <module>
NameError: name 'OBJECT_LENGTH' is not defined

Using eval is wrong many times over. Let's use something else.

``` kanzure@deathfortress:~/code/pokecrystal$ python extras/pokemontools/gbz80disasm.py 0x45f Traceback (most recent call last): File "extras/pokemontools/gbz80disasm.py", line 934, in <module> disasm.initialize() File "extras/pokemontools/gbz80disasm.py", line 619, in initialize self.wram.initialize() File "/home/kanzure/code/pokecrystal/extras/pokemontools/wram.py", line 106, in initialize self.setup_wram_sections() File "/home/kanzure/code/pokecrystal/extras/pokemontools/wram.py", line 128, in setup_wram_sections self.wram_sections = self.read_wram_sections() File "/home/kanzure/code/pokecrystal/extras/pokemontools/wram.py", line 121, in read_wram_sections wram_sections = read_bss_sections(wram_content) File "/home/kanzure/code/pokecrystal/extras/pokemontools/wram.py", line 48, in read_bss_sections length = eval(line[3:line.find(';')].replace('$','0x')) File "<string>", line 1, in <module> NameError: name 'OBJECT_LENGTH' is not defined ``` Using eval is wrong many times over. Let's use something else.
This discussion has been locked. Commenting is limited to contributors.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
decomp/pokemon-reverse-engineering-tools#37
No description provided.