git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] contrib: hg-to-git: convert data to bytes for os.write

From
JWJelle van der Waa <jelle@vdwaa.nl>
Date
Apr 1, 2019, 18:52 UTC
Message-ID
<20190401185208.17031-4-jelle@vdwaa.nl>
In-Reply-To
<20190401185208.17031-1-jelle@vdwaa.nl>
From: Jelle van der Waa <jelle@vdwaa.nl>

In Python 3 os.write wants bytes instead of a string, decode the str in to bytes.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
---
 contrib/hg-to-git/hg-to-git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py
index d504624c63..26c7300011 100755
--- a/contrib/hg-to-git/hg-to-git.py
+++ b/contrib/hg-to-git/hg-to-git.py
@@ -178,7 +178,7 @@ def getgitenv(user, date):
     #get comment
     (fdcomment, filecomment) = tempfile.mkstemp()
     csetcomment = os.popen('hg log -r %d --template "{desc}"' % cset).read().strip()
-    os.write(fdcomment, csetcomment)
+    os.write(fdcomment, csetcomment.encode())
     os.close(fdcomment)
 
     print('-----------------------------------------')
-- 
2.21.0
Previous: Jelle van der WaaNext: Jelle van der Waa
Message 3 of 4 in “Make hg-to-git contrib script Python 3 compatible”
  1. 0/3 Make hg-to-git contrib script Python 3 compatibleJelle van der Waa, Apr 1, 2019
  2. 1/3 contrib: hg-to-git: make print python 3 compatibleJelle van der Waa, Apr 1, 2019
  3. 3/3 contrib: hg-to-git: convert data to bytes for os.writeJelle van der Waa, Apr 1, 2019
  4. 2/3 contrib: hg-to-git: has_key is removed in Python 3Jelle van der Waa, Apr 1, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.