File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,13 @@ def __init__(
179179 :param param_file: Path to a parameter file.
180180 :param allow_subst: Allow substitutions in the parameter file.
181181 """
182+ # In Python, __del__ is called even if the constructor throws an
183+ # exception. It is possible for ensure_argument_type() below to
184+ # throw an exception and try to access these member variables
185+ # during cleanup, so make sure to initialize them here.
186+ self .__evaluated_param_file : Optional [Path ] = None
187+ self .__created_tmp_file = False
188+
182189 ensure_argument_type (
183190 param_file ,
184191 SomeSubstitutionsType_types_tuple + (os .PathLike , bytes ),
@@ -196,8 +203,6 @@ def __init__(
196203 self .__param_file = normalize_to_list_of_substitutions (param_file )
197204 self .__allow_substs = normalize_typed_substitution (allow_substs , data_type = bool )
198205 self .__evaluated_allow_substs : Optional [bool ] = None
199- self .__evaluated_param_file : Optional [Path ] = None
200- self .__created_tmp_file = False
201206
202207 @property
203208 def param_file (self ) -> Union [FilePath , List [Substitution ]]:
You can’t perform that action at this time.
0 commit comments