@@ -79,6 +79,25 @@ def is_sandboxed_configuration(conf):
79
79
return conf == CONFIGURATION_SANDBOXED or conf == CONFIGURATION_SANDBOXED_MULTI
80
80
81
81
82
+ # from six
83
+ def add_metaclass (metaclass ):
84
+ """Class decorator for creating a class with a metaclass."""
85
+ def wrapper (cls ):
86
+ orig_vars = cls .__dict__ .copy ()
87
+ slots = orig_vars .get ('__slots__' )
88
+ if slots is not None :
89
+ if isinstance (slots , str ):
90
+ slots = [slots ]
91
+ for slots_var in slots :
92
+ orig_vars .pop (slots_var )
93
+ orig_vars .pop ('__dict__' , None )
94
+ orig_vars .pop ('__weakref__' , None )
95
+ if hasattr (cls , '__qualname__' ):
96
+ orig_vars ['__qualname__' ] = cls .__qualname__
97
+ return metaclass (cls .__name__ , cls .__bases__ , orig_vars )
98
+ return wrapper
99
+
100
+
82
101
@contextmanager
83
102
def environ (env ):
84
103
def _handle_var (key_value ):
@@ -106,7 +125,8 @@ def _handle_var(key_value):
106
125
# the vm definitions
107
126
#
108
127
# ----------------------------------------------------------------------------------------------------------------------
109
- class AbstractPythonVm (Vm , metaclass = ABCMeta ):
128
+ @add_metaclass (ABCMeta )
129
+ class AbstractPythonVm (Vm ):
110
130
def __init__ (self , config_name , options = None , env = None ):
111
131
super (AbstractPythonVm , self ).__init__ ()
112
132
self ._config_name = config_name
@@ -154,7 +174,8 @@ def run(self, cwd, args):
154
174
return ret_code , out .data
155
175
156
176
157
- class AbstractPythonIterationsControlVm (AbstractPythonVm , metaclass = ABCMeta ):
177
+ @add_metaclass (ABCMeta )
178
+ class AbstractPythonIterationsControlVm (AbstractPythonVm ):
158
179
def __init__ (self , config_name , options = None , env = None , iterations = None ):
159
180
super (AbstractPythonIterationsControlVm , self ).__init__ (config_name , options = options , env = env )
160
181
try :
0 commit comments