Allow writing byte strings with safe_write
Heat files map keeps file contents as byte string in some cases (i.e. shell scripts). Decode them before writing to archive. Closes-Bug: #1915368 Change-Id: I3af14190ebb9d7efbb063299037bd51e38eccd83
This commit is contained in:
parent
f20fa8aaea
commit
3f6bfbaa69
|
@ -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