From f26d819aad881001d892fa6b0c28721f7f6fb4b9 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Tue, 9 Jan 2018 16:37:57 +0000 Subject: [PATCH] utils/exec_control: Fix once decorator implementation Ensures that the once decorator does not affect classes in a parallel inheritance hierarchy. --- wa/utils/exec_control.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/wa/utils/exec_control.py b/wa/utils/exec_control.py index 04d84e10..ef2fb3e3 100644 --- a/wa/utils/exec_control.py +++ b/wa/utils/exec_control.py @@ -1,5 +1,3 @@ -from inspect import getmro - # "environment" management: __environments = {} __active_environment = None @@ -96,10 +94,7 @@ def once(method): if __active_environment is None: activate_environment('default') - func_id = repr(method.func_name) - # Store the least derived class, which isn't object, to account - # for subclasses. - func_id += repr(getmro(args[0].__class__)[-2]) + func_id = repr(method.__code__) if func_id in __environments[__active_environment]: return