Skip to content

Commit

Permalink
Fix: Encode the output file properly for Python 2 runs
Browse files Browse the repository at this point in the history
Avoid compatibility errors with the `open(...)` function in Python 2 for
setting the file's encoding.

Sometimes in case an old architecture and `cms-sw` release is being
used, a Python 2 interpreter is available for executing the
`run_the_matrix_pdmv.py` module and there are compatibility issues with
the encoding argument.
  • Loading branch information
ggonzr committed Jan 20, 2025
1 parent 5ea8487 commit 03f75cf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/utils/run_the_matrix_pdmv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import print_function

import argparse
import codecs
import importlib
import inspect
import json
Expand Down Expand Up @@ -312,7 +313,7 @@ def main():
print('All workflows:')
print(json.dumps(workflows, indent=2, sort_keys=True))
if opt.output_file:
with open(opt.output_file, 'w', encoding='utf-8') as workflows_file:
with codecs.open(opt.output_file, 'w', encoding='utf-8') as workflows_file:
json.dump(workflows, workflows_file)


Expand Down

0 comments on commit 03f75cf

Please sign in to comment.