From 093575e135bc952f2f091ed60a0ac5dfad174bb9 Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Thu, 18 Apr 2024 11:39:59 +0200 Subject: [PATCH] fix(File): fix secure write when opening in binary mode --- src/DIRAC/Core/Utilities/File.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DIRAC/Core/Utilities/File.py b/src/DIRAC/Core/Utilities/File.py index 79ecbdeb240..9548faea8a6 100755 --- a/src/DIRAC/Core/Utilities/File.py +++ b/src/DIRAC/Core/Utilities/File.py @@ -273,7 +273,7 @@ def secureOpenForWrite(filename=None, *, text=True): ) else: fd, filename = tempfile.mkstemp(text=text) - with open(fd, "w" if text else "wb", encoding="ascii") as fd: + with open(fd, "w" if text else "wb", encoding="ascii" if text else None) as fd: yield fd, filename