mirror of
https://github.com/python/cpython.git
synced 2025-08-29 13:15:11 +00:00
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.)
This commit is contained in:
parent
452bf519a7
commit
be19ed77dd
331 changed files with 2567 additions and 2648 deletions
|
@ -21,10 +21,10 @@ def task(ident):
|
|||
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 @@ def newtask():
|
|||
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 @@ def newtask():
|
|||
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 @@ def task2(ident):
|
|||
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 @@ def task2(ident):
|
|||
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 @@ running = numtasks
|
|||
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 @@ if os_name in ("nt", "os2", "posix"):
|
|||
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 @@ if os_name in ("nt", "os2", "posix"):
|
|||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue