Description: Use Python 3
Author: Jonas Smedegaard <dr@jones.dk>
Last-Update: 2019-08-30
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/Makefile.am
+++ b/Makefile.am
@@ -52,15 +52,15 @@
 check: gesftpserver sftpclient pwtest aliases
 	rm -f *.gcda *.gcov
 	./pwtest
-	srcdir=${srcdir} ${PYTHON24} ${srcdir}/run-tests --directory tests $(TESTS)
-	srcdir=${srcdir} ${PYTHON24} ${srcdir}/run-tests --directory rotests --server ./gesftpserver-ro $(ROTESTS)
-	${GCOV} ${srcdir}/*.c  | ${PYTHON24} ${srcdir}/format-gconv-report --html .
+	srcdir=${srcdir} ${PYTHON3} ${srcdir}/run-tests --directory tests $(TESTS)
+	srcdir=${srcdir} ${PYTHON3} ${srcdir}/run-tests --directory rotests --server ./gesftpserver-ro $(ROTESTS)
+	${GCOV} ${srcdir}/*.c  | ${PYTHON3} ${srcdir}/format-gconv-report --html .
 
 #${srcdir}/paramiko-test
 
 check-valgrind: gesftpserver-valgrind sftpclient pwtest aliases
 	rm -f ,valgrind*
-	srcdir=${srcdir} ${PYTHON24} ${srcdir}/run-tests --directory tests --server ./gesftpserver-valgrind $(TESTS)
+	srcdir=${srcdir} ${PYTHON3} ${srcdir}/run-tests --directory tests --server ./gesftpserver-valgrind $(TESTS)
 
 aliases: gesftpserver-ro gesftpserver-debug gesftpserver-ro-debug \
 		gesftpserver-valgrind
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -250,28 +250,26 @@
   ])
 ])
 
-AC_DEFUN([RJK_PYTHON24],[
-  AC_CACHE_CHECK([for Python 2.4 or better],[rjk_cv_python24],[
-    if python24 -V >/dev/null 2>&1; then
-      rjk_cv_python24=python24
-    elif python2.4 -V >/dev/null 2>&1; then
-      rjk_cv_python24=python2.4
+AC_DEFUN([RJK_PYTHON3],[
+  AC_CACHE_CHECK([for Python 3 or better],[rjk_cv_python3],[
+    if python3 -V >/dev/null 2>&1; then
+      rjk_cv_python3=python3
     elif python -V >confpyver 2>&1; then
       read p v < confpyver
       case "$v" in
-      1* | 2.0* | 2.1* | 2.2* | 2.3* )
+      1* | 2* )
         ;;
       * )
-        rjk_cv_python24=python
+        rjk_cv_python3=python
         ;;
       esac
     fi
     rm -f confpyver
-    if test "$rjk_cv_python24" = ""; then
-      AC_MSG_ERROR([cannot find Python 2.4 or better])
+    if test "$rjk_cv_python3" = ""; then
+      AC_MSG_ERROR([cannot find Python 3 or better])
     fi
   ])
-  AC_SUBST([PYTHON24],[$rjk_cv_python24])
+  AC_SUBST([PYTHON3],[$rjk_cv_python3])
 ])
 
 dnl Local Variables:
--- a/configure.ac
+++ b/configure.ac
@@ -55,7 +55,7 @@
 RJK_GCC_ATTRS
 RJK_STAT_TIMESPEC
 RJK_GETOPT
-RJK_PYTHON24
+RJK_PYTHON3
 
 dnl See commentary in v3.c for what's going on here
 AC_MSG_CHECKING([whether to reverse SSH_FXP_SYMLINK arguments])
--- a/format-gconv-report
+++ b/format-gconv-report
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 # This file is part of the Green End SFTP Server.
 # Copyright (C) 2007 Richard Kettlewell
 #
@@ -29,7 +29,7 @@
     return c
 
 def sgmlquote(s):
-  return string.join(map(sgmlquotechar, s),'')
+  return string.join(list(map(sgmlquotechar, s)),'')
 
 percent = {}
 total_lines = 0
@@ -64,13 +64,13 @@
   elif percent[a] > percent[b]: return 1
   else: return 0
 
-keys = percent.keys()
+keys = list(percent.keys())
 keys.sort(cmp)
 
 if len(keys):
   for k in keys:
-    print "%20s: %d%%" % (k, percent[k])
-  print "Total coverage: %d%%" % (100 * (covered_lines / total_lines))
+    print("%20s: %d%%" % (k, percent[k]))
+  print("Total coverage: %d%%" % (100 * (covered_lines / total_lines)))
 
 if htmldir is not None and len(keys):
   index = open(os.path.join(htmldir, "index.html"), "w")
--- a/run-tests
+++ b/run-tests
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 #
 # This file is part of the Green End SFTP Server.
 # Copyright (C) 2007, 2011, 2016 Richard Kettlewell
@@ -29,7 +29,7 @@
 def rmrf(path):
     if os.path.lexists(path):
         if (not os.path.islink(path)) and os.path.isdir(path):
-            os.chmod(path, 0700)
+            os.chmod(path, 0o700)
             for name in os.listdir(path):
                 rmrf(os.path.join(path,name))
             os.rmdir(path)
@@ -43,7 +43,7 @@
 if os.getuid() == 0:
     fatal("These tests are not suitable for running as root.")
 
-os.umask(022)                           # for consistent permissions
+os.umask(0o22)                           # for consistent permissions
 failed = 0
 protocols = ['2', '3', '4', '5', '6', '7']
 dir = 'tests'
@@ -120,7 +120,7 @@
                         errors.append("EXPECTED[%d]: %s" % (n + 1, expected))
                         errors.append("     GOT[%d]: %s" % (n + 1, got))
                 except:
-                    print "\n\nPossible invalid regexp:\n%s\n" % expected
+                    print("\n\nPossible invalid regexp:\n%s\n" % expected)
                     raise
             else:
                 if expected != got:
@@ -145,12 +145,12 @@
             sys.stderr.write("passed\n")
 
 if failed:
-    print "%d tests failed" % failed
+    print("%d tests failed" % failed)
     sys.exit(1)
 else:
     os.chdir("/")
     rmrf(os.path.join(builddir, ',testroot'))
-    print "OK"
+    print("OK")
 
 # Local Variables:
 # mode:python
