Merge "Allow writing byte strings with safe_write"
This commit is contained in:
commit
7f01c55212
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue