Skip to content

Commit 85fc38c

Browse files
author
Peter Amstutz
committed
Add a comment about the insanity.
1 parent b3e5da9 commit 85fc38c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cwltool/process.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,16 @@ def _init_job(self, joborder, runtimeContext):
727727
if six.PY3:
728728
key = cmp_to_key(cmp_like_py2)
729729
else: # PY2
730-
key = lambda dict: dict["position"]
731-
bindings[:] = sorted(bindings, key=key)
730+
key = lambda d: d["position"]
731+
732+
# This awkward construction replaces the contents of
733+
# "bindings" in place (because Builder expects it to be
734+
# mutated in place, sigh, I'm sorry) with its contents sorted,
735+
# supporting different versions of Python and ruamel.yaml with
736+
# different behaviors/bugs in CommentedSeq.
737+
bd = copy.deepcopy(bindings)
738+
del bindings[:]
739+
bindings.extend(sorted(bd, key=key))
732740

733741
if self.tool[u"class"] != 'Workflow':
734742
builder.resources = self.evalResources(builder, runtimeContext)

0 commit comments

Comments
 (0)