Skip to content

Commit 1c40dce

Browse files
authored
Merge pull request #5706 from chrisburr/dencode-dict
[v7r2] Fix encodeDict when the dict keys have mixed types
2 parents 8aa94a0 + e5cb5e6 commit 1c40dce

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/DIRAC/Core/Utilities/DEncode.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,13 @@ def encodeDict(dValue, eList):
499499
printDebugCallstack("Encoding dict with numeric keys")
500500

501501
eList.append(b"d")
502-
for key in sorted(dValue):
502+
if six.PY2:
503+
iterVar = sorted(dValue)
504+
else:
505+
# Some systems write dictionaries which a mix of string + int keys
506+
# Only remove sorted with Python 3 to minimise the chance of regressions
507+
iterVar = dValue
508+
for key in iterVar:
503509
g_dEncodeFunctions[type(key)](key, eList)
504510
g_dEncodeFunctions[type(dValue[key])](dValue[key], eList)
505511
eList.append(b"e")

0 commit comments

Comments
 (0)