1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
From: David Rabel <david.rabel@noresoft.com>
Date: Tue, 4 Sep 2018 11:59:52 +0200
Subject: Encode string before writing it to file
Forwarded: https://github.com/fmoo/python-editor/pull/18
This is to prevent a python3 error:
TypeError: a bytes-like object is required, not 'str'
---
editor.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/editor.py b/editor.py
index 54ee697..38efc6e 100755
--- a/editor.py
+++ b/editor.py
@@ -86,7 +86,7 @@ def edit(filename=None, contents=None, use_tty=None):
if contents is not None:
with open(filename, mode='wb') as f:
- f.write(contents)
+ f.write(contents.encode())
args += [filename]
|