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

[PATCH v2 8/8] git-remote-testpy: call print as a function

From
John Keeping <john@keeping.me.uk>
Date
Jan 17, 2013, 18:54 UTC
Message-ID
<88502ee7b090454352b46d496741029817b27482.1358448207.git.john@keeping.me.uk>
In-Reply-To
<cover.1358448207.git.john@keeping.me.uk>

This is harmless in Python 2, which sees the parentheses as redundant grouping, but is required for Python 3. Since this is the only change required to make this script just run under Python 3 without needing 2to3 it seems worthwhile.

The case of an empty print must be handled specially because in that case Python 2 will interpret '()' as an empty tuple and print it as '()'; inserting an empty string fixes this.

Signed-off-by: John Keeping <john@keeping.me.uk>
---
 git-remote-testpy.py | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/git-remote-testpy.py b/git-remote-testpy.py
index bc5e3cf..ccdb2dc 100644
--- a/git-remote-testpy.py
+++ b/git-remote-testpy.py
@@ -87,9 +87,9 @@ def do_capabilities(repo, args):
     """Prints the supported capabilities.
     """
 
-    print "import"
-    print "export"
-    print "refspec refs/heads/*:%s*" % repo.prefix
+    print("import")
+    print("export")
+    print("refspec refs/heads/*:%s*" % repo.prefix)
 
     dirname = repo.get_base_path(repo.gitdir)
 
@@ -98,11 +98,11 @@ def do_capabilities(repo, args):
 
     path = os.path.join(dirname, 'git.marks')
 
-    print "*export-marks %s" % path
+    print("*export-marks %s" % path)
     if os.path.exists(path):
-        print "*import-marks %s" % path
+        print("*import-marks %s" % path)
 
-    print # end capabilities
+    print('') # end capabilities
 
 
 def do_list(repo, args):
@@ -115,16 +115,16 @@ def do_list(repo, args):
 
     for ref in repo.revs:
         debug("? refs/heads/%s", ref)
-        print "? refs/heads/%s" % ref
+        print("? refs/heads/%s" % ref)
 
     if repo.head:
         debug("@refs/heads/%s HEAD" % repo.head)
-        print "@refs/heads/%s HEAD" % repo.head
+        print("@refs/heads/%s HEAD" % repo.head)
     else:
         debug("@refs/heads/master HEAD")
-        print "@refs/heads/master HEAD"
+        print("@refs/heads/master HEAD")
 
-    print # end list
+    print('') # end list
 
 
 def update_local_repo(repo):
@@ -164,7 +164,7 @@ def do_import(repo, args):
         ref = line[7:].strip()
         refs.append(ref)
 
-    print "feature done"
+    print("feature done")
 
     if os.environ.get("GIT_REMOTE_TESTGIT_FAILURE"):
         die('Told to fail')
@@ -172,7 +172,7 @@ def do_import(repo, args):
     repo = update_local_repo(repo)
     repo.exporter.export_repo(repo.gitdir, refs)
 
-    print "done"
+    print("done")
 
 
 def do_export(repo, args):
@@ -192,8 +192,8 @@ def do_export(repo, args):
         repo.non_local.push(repo.gitdir)
 
     for ref in changed:
-        print "ok %s" % ref
-    print
+        print("ok %s" % ref)
+    print('')
 
 
 COMMANDS = {
-- 
1.8.1.1.260.g99b33f4.dirty
Previous: Sverre RabbelierNext: Sverre Rabbelier
Message 52 of 53 in “Initial support for Python 3”
  1. 0/8 Initial support for Python 3John Keeping, Jan 12, 2013
  2. 1/8 git_remote_helpers: Allow building with Python 3John Keeping, Jan 12, 2013
  3. 2/8 git_remote_helpers: fix input when running under Python 3John Keeping, Jan 12, 2013
  4. Michael HaggertyJan 13, 2013
  5. John KeepingJan 13, 2013
  6. Michael HaggertyJan 14, 2013
  7. John KeepingJan 14, 2013
  8. 2/8 git_remote_helpers: fix input when running under Python 3John Keeping, Jan 15, 2013
  9. Junio C HamanoJan 15, 2013
  10. John KeepingJan 15, 2013
  11. Junio C HamanoJan 15, 2013
  12. 2/8 git_remote_helpers: fix input when running under Python 3John Keeping, Jan 15, 2013
  13. Pete WyckoffJan 16, 2013
  14. John KeepingJan 16, 2013
  15. Pete WyckoffJan 17, 2013
  16. 3/8 git_remote_helpers: Force rebuild if python version changesJohn Keeping, Jan 12, 2013
  17. Pete WyckoffJan 12, 2013
  18. John KeepingJan 13, 2013
  19. Pete WyckoffJan 13, 2013
  20. John KeepingJan 13, 2013
  21. John KeepingJan 15, 2013
  22. Pete WyckoffJan 17, 2013
  23. 4/8 git_remote_helpers: Use 2to3 if building with Python 3John Keeping, Jan 12, 2013
  24. 5/8 svn-fe: allow svnrdump_sim.py to run with Python 3John Keeping, Jan 12, 2013
  25. 6/8 git-remote-testpy: hash bytes explicitlyJohn Keeping, Jan 12, 2013
  26. 7/8 git-remote-testpy: don't do unbuffered text I/OJohn Keeping, Jan 12, 2013
  27. 8/8 git-remote-testpy: call print as a functionJohn Keeping, Jan 12, 2013
  28. Pete WyckoffJan 12, 2013
  29. John KeepingJan 13, 2013
  30. John KeepingJan 13, 2013
  31. Pete WyckoffJan 13, 2013
  32. John KeepingJan 13, 2013
  33. 0/8 Initial Python 3 supportJohn Keeping, Jan 17, 2013
  34. 1/8 git_remote_helpers: allow building with Python 3John Keeping, Jan 17, 2013
  35. 2/8 git_remote_helpers: fix input when running under Python 3John Keeping, Jan 17, 2013
  36. 3/8 git_remote_helpers: force rebuild if python version changesJohn Keeping, Jan 17, 2013
  37. 4/8 git_remote_helpers: use 2to3 if building with Python 3John Keeping, Jan 17, 2013
  38. Sverre RabbelierJan 18, 2013
  39. John KeepingJan 18, 2013
  40. Sverre RabbelierJan 19, 2013
  41. 5/8 svn-fe: allow svnrdump_sim.py to run with Python 3John Keeping, Jan 17, 2013
  42. 6/8 git-remote-testpy: hash bytes explicitlyJohn Keeping, Jan 17, 2013
  43. Junio C HamanoJan 17, 2013
  44. Junio C HamanoJan 17, 2013
  45. John KeepingJan 17, 2013
  46. John KeepingJan 17, 2013
  47. Junio C HamanoJan 17, 2013
  48. John KeepingJan 17, 2013
  49. Junio C HamanoJan 17, 2013
  50. 7/8 git-remote-testpy: don't do unbuffered text I/OJohn Keeping, Jan 17, 2013
  51. Sverre RabbelierJan 18, 2013
  52. 8/8 git-remote-testpy: call print as a functionJohn Keeping, Jan 17, 2013
  53. Sverre RabbelierJan 18, 2013

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.