Fixed open tempfile.NamedTemporaryFile as text in Python3
Python3 opens tempfile by default as binary[1] and not as ascii,
and nvmetcli writes json output as ascii.
This issue was overlooked with Python2, since binary and ascii
variables are less distiguished there.
[1]
[2]
Closes-Bug:
@@ -83,7 +83,7 @@ class NVMET(nvmeof.NVMeOF):
def _restore(self, nvmf_subsystems):
# Dump updated JSON dict to append new subsystem
- with tempfile.NamedTemporaryFile() as tmp_fd:
+ with tempfile.NamedTemporaryFile(mode='w') as tmp_fd:
tmp_fd.write(json.dumps(nvmf_subsystems))
tmp_fd.flush()
try:
