"dynamic" variables cause KeyError at return
Posted: Sat Mar 07, 2015 3:51 pm
Hi again.
I don't know whether it is feature or bug but if I would write something like this:
and call label "test" when variable "a" is undefined, then at "return" statement method pop_dynamic (execution.py, line 210) would raise KeyError trying to del undefined attribute "a" from the store. If variable "a" was defined before the call, no exception raised. It seems like not a very consistent behavior.
Personally I would prefer to be able to "declare" all variables, that might be used within callable label, at once and do not care lately whether I assign them or not.
To achieve this It's possible to add simple "in" check into for loop within pop_dynamic() method:
So, is it a feature or bug that I must to assign every "dynamic" variable?
PS. Sorry for my English... It's rather difficult for me to express my thoughts. Hope you will be able to understand.
I don't know whether it is feature or bug but if I would write something like this:
Code: Select all
label test:
renpy.dynamic('a')
return
Personally I would prefer to be able to "declare" all variables, that might be used within callable label, at once and do not care lately whether I assign them or not.
To achieve this It's possible to add simple "in" check into for loop within pop_dynamic() method:
Code: Select all
for k, v in dynamic.iteritems():
if isinstance(v, Delete):
if k in store: # check if dynamic variable was assigned
del store[k]
else:
store[k] = v
PS. Sorry for my English... It's rather difficult for me to express my thoughts. Hope you will be able to understand.