Skip to content

Commit 8d790b4

Browse files
author
David Stirling
authored
Fix loading of older cpproj files (#85)
1 parent 1a5213a commit 8d790b4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cellprofiler_core/workspace/_workspace.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,16 @@ def load(self, filename, load_pipeline):
387387
.decode("unicode_escape")
388388
.replace("ÿþ", "")
389389
)
390+
if "\\n" in pipeline_txt:
391+
# Loaded pipeline text from a pre-h5py 3 hdf5 will have escaped characters in need of decoding.
392+
try:
393+
pipeline_txt = pipeline_txt.encode(
394+
"latin-1", "backslashreplace"
395+
).decode("unicode-escape")
396+
except Exception as e:
397+
print(
398+
f"Unable to fully decode pipeline, you may encounter some errors. Issue was: {e}"
399+
)
390400
self.pipeline.load(io.StringIO(pipeline_txt))
391401
elif load_pipeline:
392402
self.pipeline.clear()

0 commit comments

Comments
 (0)