first set of semantic changes for python3
[nepi.git] / src / nepi / resources / linux / node.py
index b440038..7558475 100644 (file)
@@ -765,7 +765,9 @@ class LinuxNode(ResourceManager):
         if text and not os.path.isfile(src):
             # src is text input that should be uploaded as file
             # create a temporal file with the content to upload
-            f = tempfile.NamedTemporaryFile(delete=False)
+            # in python3 we need to open in binary mode if str is bytes
+            mode = 'w' if isinstance(src, str) else 'wb'
+            f = tempfile.NamedTemporaryFile(mode=mode, delete=False)
             f.write(src)
             f.close()
             src = f.name