Fix most trivially-findable print statements.
There's one major and one minor category still unfixed:
doctests are the major category (and I hope to be able to augment the
refactoring tool to refactor bona fide doctests soon);
other code generating print statements in strings is the minor category.
(Oh, and I don't know if the compiler package works.)
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 0b37306..6cc52ea 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -106,8 +106,7 @@
(err, msg) = e
if err != errno.EADDRINUSE:
raise
- print >>sys.__stderr__, \
- ' WARNING: failed to listen on port %d, trying another' % port
+ print(' WARNING: failed to listen on port %d, trying another' % port, file=sys.__stderr__)
raise TestFailed, 'unable to find port to listen on'
FUZZ = 1e-6
@@ -178,10 +177,9 @@
except UnicodeEncodeError:
pass
else:
- print \
- 'WARNING: The filename %r CAN be encoded by the filesystem. ' \
+ print('WARNING: The filename %r CAN be encoded by the filesystem. ' \
'Unicode filename tests may not be effective' \
- % TESTFN_UNICODE_UNENCODEABLE
+ % TESTFN_UNICODE_UNENCODEABLE)
# Make sure we can write to TESTFN, try in /tmp if we can't
fp = None
@@ -194,8 +192,8 @@
TESTFN = TMP_TESTFN
del TMP_TESTFN
except IOError:
- print ('WARNING: tests will fail, unable to write to: %s or %s' %
- (TESTFN, TMP_TESTFN))
+ print(('WARNING: tests will fail, unable to write to: %s or %s' %
+ (TESTFN, TMP_TESTFN)))
if fp is not None:
fp.close()
unlink(TESTFN)
@@ -267,7 +265,7 @@
return open(fn)
requires('urlfetch')
- print >> get_original_stdout(), '\tfetching %s ...' % url
+ print('\tfetching %s ...' % url, file=get_original_stdout())
fn, _ = urllib.urlretrieve(url, filename)
return open(fn)
@@ -514,7 +512,7 @@
finally:
sys.stdout = save_stdout
if verbose:
- print 'doctest (%s) ... %d tests with zero failures' % (module.__name__, t)
+ print('doctest (%s) ... %d tests with zero failures' % (module.__name__, t))
return f, t
#=======================================================================