Handle ConfigFlag values of None
I encountered some very unintuitive behaviour, where loading dynamic flags on a locked ConfigFlags
instance caused:
File ".../AthConfigFlags.py", line 277, in _get
return self._flagdict[name].get(self)
File ".../AthConfigFlags.py", line 65, in get
self._value=self._setDef(flagdict)
TypeError: 'NoneType' object is not callable
In this instance, the value of the flags was assigned to be None
.
The problem here is the logic used for locking.
- Unlocked flags with a value of
None
will returnself._setDef(flagdict)
freely - Locked flags with a value of
None
attempt to set the value once and then set_setDef=None
. - Trying to get the value later fails because the
_setDef
call is always attempted.
The fix is to check if both _setDef
and _value
are None
, in which case the None
value is the intended one. This is a little convoluted, so maybe it might be better to assign a '_valueSet' flag instead, but this worked to get out of my corner case.
Tagging @wlampl for info, @jmasik in case the fix is useful before merging because ID trigger flags have a number of such None
values, one of which triggered my problem.