Merge "Allow writing byte strings with safe_write"

This commit is contained in:
Zuul 2021-02-16 05:25:48 +00:00 committed by Gerrit Code Review
commit 7f01c55212
1 changed files with 5 additions and 0 deletions

View File

@ -2402,6 +2402,11 @@ def safe_write(path, data):
path
)
try:
data = data.decode('utf-8', 'ignore')
except (UnicodeDecodeError, AttributeError):
pass
try:
with os.fdopen(os.open(path,
os.O_CREAT | os.O_TRUNC | os.O_WRONLY, 0o666),