Skip to content

Commit 3235d81

Browse files
Merge pull request #302 from thombashi/fix_make_test_python3
Fix "make test" in Python 3
2 parents 3f97f78 + 534e341 commit 3235d81

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

test/testall.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Run the test suite against all the Python versions we can find.
44
#
55

6+
from __future__ import print_function
7+
68
import sys
79
import os
810
from os.path import dirname, abspath, join
@@ -46,7 +48,7 @@ def testall():
4648
# Don't support Python < 2.3.
4749
continue
4850
ver_str = "%s.%s" % ver
49-
print "-- test with Python %s (%s)" % (ver_str, python)
51+
print("-- test with Python %s (%s)" % (ver_str, python))
5052
assert ' ' not in python
5153
rv = os.system("MACOSX_DEPLOYMENT_TARGET= %s test.py -- -knownfailure" % python)
5254
if rv:

tools/which.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
from HKLM\SOFTWARE\...\perl.exe
3434
"""
3535

36+
from __future__ import print_function
37+
3638
_cmdlnUsage = """
3739
Show the full path of commands.
3840
@@ -287,17 +289,17 @@ def main(argv):
287289
try:
288290
optlist, args = getopt.getopt(argv[1:], 'haVvqp:e:',
289291
['help', 'all', 'version', 'verbose', 'quiet', 'path=', 'exts='])
290-
except getopt.GetoptError, msg:
292+
except getopt.GetoptError as msg:
291293
sys.stderr.write("which: error: %s. Your invocation was: %s\n"\
292294
% (msg, argv))
293295
sys.stderr.write("Try 'which --help'.\n")
294296
return 1
295297
for opt, optarg in optlist:
296298
if opt in ('-h', '--help'):
297-
print _cmdlnUsage
299+
print(_cmdlnUsage)
298300
return 0
299301
elif opt in ('-V', '--version'):
300-
print "which %s" % __version__
302+
print("which %s" % __version__)
301303
return 0
302304
elif opt in ('-a', '--all'):
303305
all = 1
@@ -325,9 +327,9 @@ def main(argv):
325327
nmatches = 0
326328
for match in whichgen(arg, path=altpath, verbose=verbose, exts=exts):
327329
if verbose:
328-
print "%s (%s)" % match
330+
print("%s (%s)" % match)
329331
else:
330-
print match
332+
print(match)
331333
nmatches += 1
332334
if not all:
333335
break

0 commit comments

Comments
 (0)