diff --git a/jwst/stpipe/core.py b/jwst/stpipe/core.py index 3e8fe562fe..2cedc04f1e 100644 --- a/jwst/stpipe/core.py +++ b/jwst/stpipe/core.py @@ -101,8 +101,10 @@ def finalize_result(self, result, reference_files_used): if hasattr(result, 'cal_logs'): tmpdict = result.cal_logs.instance - tmpdict[self.class_alias] = '\n'.join(self._log_records) - result.cal_logs = tmpdict + else: + tmpdict = dict() + tmpdict[self.class_alias] = '\n'.join(self._log_records) + result.cal_logs = tmpdict def remove_suffix(self, name): return remove_suffix(name) @@ -138,9 +140,11 @@ def finalize_result(self, result, reference_files_used): if hasattr(result, 'cal_logs'): tmpdict = result.cal_logs.instance - tmpdict[self.class_alias] = '\n'.join(self._log_records) + else: + tmpdict = dict() + tmpdict[self.class_alias] = '\n'.join(self._log_records) - for _, step in self.step_defs.items(): - if step.class_alias in tmpdict.keys(): - del tmpdict[step.class_alias] - result.cal_logs = tmpdict + for _, step in self.step_defs.items(): + if step.class_alias in tmpdict.keys(): + del tmpdict[step.class_alias] + result.cal_logs = tmpdict