From 3770489a493d43e980fa275b3bb16b807ed4e065 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 13 Sep 2017 02:31:19 +0530 Subject: [PATCH] Writing bytes to NamedTemporaryFile --- hosting/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosting/forms.py b/hosting/forms.py index 458bee6f..bcc957b9 100644 --- a/hosting/forms.py +++ b/hosting/forms.py @@ -97,7 +97,7 @@ class UserHostingKeyForm(forms.ModelForm): openssh_pubkey_str = self.data.get('public_key') with tempfile.NamedTemporaryFile(delete=True) as tmp_public_key_file: - tmp_public_key_file.writelines(openssh_pubkey_str) + tmp_public_key_file.write(openssh_pubkey_str.encode('utf-8')) tmp_public_key_file.flush() try: out = subprocess.check_output(