Skip to content

Commit 4b7af95

Browse files
committed
fix: Supress non-UTF8 variables from pilot environment
1 parent c26c483 commit 4b7af95

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/DIRAC/WorkloadManagementSystem/Utilities/PilotWrapper.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,15 @@
6868
# just logging the environment as first thing
6969
logger.debug('===========================================================')
7070
logger.debug('Environment of execution host\\n')
71-
for key, val in os.environ.items():
71+
for key, val in getattr(os, "environb", os.environ).items():
72+
# Clean the environment of non-utf-8 characters
73+
try:
74+
key = key.decode("utf-8")
75+
val = val.decode("utf-8")
76+
except UnicodeDecodeError as e:
77+
logger.error("Dropping %%s=%%s due to: %%s", key, val, e)
78+
del os.environ[key]
79+
continue
7280
logger.debug(key + '=' + val)
7381
logger.debug('===========================================================\\n')
7482

0 commit comments

Comments
 (0)