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_thread.py b/Lib/test/test_thread.py
index c4c21fe..5705798 100644
--- a/Lib/test/test_thread.py
+++ b/Lib/test/test_thread.py
@@ -21,10 +21,10 @@
delay = random.random() * numtasks
rmutex.release()
if verbose:
- print 'task', ident, 'will run for', round(delay, 1), 'sec'
+ print('task', ident, 'will run for', round(delay, 1), 'sec')
time.sleep(delay)
if verbose:
- print 'task', ident, 'done'
+ print('task', ident, 'done')
mutex.acquire()
running = running - 1
if running == 0:
@@ -37,7 +37,7 @@
mutex.acquire()
next_ident = next_ident + 1
if verbose:
- print 'creating task', next_ident
+ print('creating task', next_ident)
thread.start_new_thread(task, (next_ident,))
running = running + 1
mutex.release()
@@ -45,9 +45,9 @@
for i in range(numtasks):
newtask()
-print 'waiting for all tasks to complete'
+print('waiting for all tasks to complete')
done.acquire()
-print 'all tasks done'
+print('all tasks done')
class barrier:
def __init__(self, n):
@@ -89,13 +89,13 @@
delay = random.random() * numtasks
rmutex.release()
if verbose:
- print 'task', ident, 'will run for', round(delay, 1), 'sec'
+ print('task', ident, 'will run for', round(delay, 1), 'sec')
time.sleep(delay)
if verbose:
- print 'task', ident, 'entering barrier', i
+ print('task', ident, 'entering barrier', i)
bar.enter()
if verbose:
- print 'task', ident, 'leaving barrier', i
+ print('task', ident, 'leaving barrier', i)
mutex.acquire()
running -= 1
# Must release mutex before releasing done, else the main thread can
@@ -106,7 +106,7 @@
if finished:
done.release()
-print '\n*** Barrier Test ***'
+print('\n*** Barrier Test ***')
if done.acquire(0):
raise ValueError, "'done' should have remained acquired"
bar = barrier(numtasks)
@@ -114,10 +114,10 @@
for i in range(numtasks):
thread.start_new_thread(task2, (i,))
done.acquire()
-print 'all tasks done'
+print('all tasks done')
# not all platforms support changing thread stack size
-print '\n*** Changing thread stack size ***'
+print('\n*** Changing thread stack size ***')
if thread.stack_size() != 0:
raise ValueError, "initial stack_size not 0"
@@ -132,10 +132,10 @@
try:
thread.stack_size(4096)
except ValueError:
- print 'caught expected ValueError setting stack_size(4096)'
+ print('caught expected ValueError setting stack_size(4096)')
except thread.error:
tss_supported = 0
- print 'platform does not support changing thread stack size'
+ print('platform does not support changing thread stack size')
if tss_supported:
failed = lambda s, e: s != e
@@ -144,17 +144,17 @@
thread.stack_size(tss)
if failed(thread.stack_size(), tss):
raise ValueError, fail_msg % tss
- print 'successfully set stack_size(%d)' % tss
+ print('successfully set stack_size(%d)' % tss)
for tss in (262144, 0x100000):
- print 'trying stack_size = %d' % tss
+ print('trying stack_size = %d' % tss)
next_ident = 0
for i in range(numtasks):
newtask()
- print 'waiting for all tasks to complete'
+ print('waiting for all tasks to complete')
done.acquire()
- print 'all tasks done'
+ print('all tasks done')
# reset stack size to default
thread.stack_size(0)