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:
Guido van Rossum 2007-02-09 05:37:30 +00:00
parent 452bf519a7
commit be19ed77dd
331 changed files with 2567 additions and 2648 deletions

View file

@ -60,10 +60,10 @@ def get_tests(package, mask, verbosity):
except ResourceDenied as detail:
skipped.append(modname)
if verbosity > 1:
print >> sys.stderr, "Skipped %s: %s" % (modname, detail)
print("Skipped %s: %s" % (modname, detail), file=sys.stderr)
continue
except Exception as detail:
print >> sys.stderr, "Warning: could not import %s: %s" % (modname, detail)
print("Warning: could not import %s: %s" % (modname, detail), file=sys.stderr)
continue
for name in dir(mod):
if name.startswith("_"):
@ -74,7 +74,7 @@ def get_tests(package, mask, verbosity):
return skipped, tests
def usage():
print __doc__
print(__doc__)
return 1
def test_with_refcounts(runner, verbosity, testcase):
@ -106,9 +106,9 @@ def test_with_refcounts(runner, verbosity, testcase):
cleanup()
refcounts[i] = sys.gettotalrefcount() - rc
if filter(None, refcounts):
print "%s leaks:\n\t" % testcase, refcounts
print("%s leaks:\n\t" % testcase, refcounts)
elif verbosity:
print "%s: ok." % testcase
print("%s: ok." % testcase)
class TestRunner(unittest.TextTestRunner):
def run(self, test, skipped):
@ -166,7 +166,7 @@ def main(*packages):
try:
sys.gettotalrefcount
except AttributeError:
print >> sys.stderr, "-r flag requires Python debug build"
print("-r flag requires Python debug build", file=sys.stderr)
return -1
search_leaks = True
elif flag == "-u":

View file

@ -15,7 +15,7 @@ def bin(s):
class Test(unittest.TestCase):
def X_test(self):
print >> sys.stderr, sys.byteorder
print(sys.byteorder, file=sys.stderr)
for i in range(32):
bits = BITS()
setattr(bits, "i%s" % i, 1)

View file

@ -22,12 +22,12 @@ else:
## print, for debugging
if is_resource_enabled("printing"):
if lib_gl or lib_glu or lib_glut or lib_gle:
print "OpenGL libraries:"
print("OpenGL libraries:")
for item in (("GL", lib_gl),
("GLU", lib_glu),
("glut", lib_glut),
("gle", lib_gle)):
print "\t", item
print("\t", item)
# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.

View file

@ -100,13 +100,13 @@ class DeletePointerTestCase(unittest.TestCase):
x = X()
i = c_char_p("abc def")
from sys import getrefcount as grc
print "2?", grc(i)
print("2?", grc(i))
x.p = pointer(i)
print "3?", grc(i)
print("3?", grc(i))
for i in range(320):
c_int(99)
x.p[0]
print x.p[0]
print(x.p[0])
## del x
## print "2?", grc(i)
## del i
@ -115,14 +115,14 @@ class DeletePointerTestCase(unittest.TestCase):
for i in range(320):
c_int(99)
x.p[0]
print x.p[0]
print x.p.contents
print(x.p[0])
print(x.p.contents)
## print x._objects
x.p[0] = "spam spam"
## print x.p[0]
print "+" * 42
print x._objects
print("+" * 42)
print(x._objects)
class PointerToStructure(unittest.TestCase):
def test(self):

View file

@ -15,7 +15,7 @@ else:
libc_name = find_library("c")
if is_resource_enabled("printing"):
print "libc_name is", libc_name
print("libc_name is", libc_name)
class LoaderTest(unittest.TestCase):
@ -44,8 +44,8 @@ class LoaderTest(unittest.TestCase):
if os.name in ("nt", "ce"):
def test_load_library(self):
if is_resource_enabled("printing"):
print find_library("kernel32")
print find_library("user32")
print(find_library("kernel32"))
print(find_library("user32"))
if os.name == "nt":
windll.kernel32.GetModuleHandleW

View file

@ -192,7 +192,7 @@ def run_test(rep, msg, func, arg=None):
for i in items:
func(); func(); func(); func(); func()
stop = clock()
print "%15s: %.2f us" % (msg, ((stop-start)*1e6/5/rep))
print("%15s: %.2f us" % (msg, ((stop-start)*1e6/5/rep)))
def check_perf():
# Construct 5 objects

View file

@ -189,7 +189,7 @@ def run_test(rep, msg, func, arg):
for i in items:
func(arg); func(arg); func(arg); func(arg); func(arg)
stop = clock()
print "%20s: %.2f us" % (msg, ((stop-start)*1e6/5/rep))
print("%20s: %.2f us" % (msg, ((stop-start)*1e6/5/rep)))
def check_perf():
# Construct 5 objects

View file

@ -125,15 +125,15 @@ elif os.name == "posix":
def test():
from ctypes import cdll
if os.name == "nt":
print cdll.msvcrt
print cdll.load("msvcrt")
print find_library("msvcrt")
print(cdll.msvcrt)
print(cdll.load("msvcrt"))
print(find_library("msvcrt"))
if os.name == "posix":
# find and load_version
print find_library("m")
print find_library("c")
print find_library("bz2")
print(find_library("m"))
print(find_library("c"))
print(find_library("bz2"))
# getattr
## print cdll.m
@ -141,14 +141,14 @@ def test():
# load
if sys.platform == "darwin":
print cdll.LoadLibrary("libm.dylib")
print cdll.LoadLibrary("libcrypto.dylib")
print cdll.LoadLibrary("libSystem.dylib")
print cdll.LoadLibrary("System.framework/System")
print(cdll.LoadLibrary("libm.dylib"))
print(cdll.LoadLibrary("libcrypto.dylib"))
print(cdll.LoadLibrary("libSystem.dylib"))
print(cdll.LoadLibrary("System.framework/System"))
else:
print cdll.LoadLibrary("libm.so")
print cdll.LoadLibrary("libcrypt.so")
print find_library("crypt")
print(cdll.LoadLibrary("libm.so"))
print(cdll.LoadLibrary("libcrypt.so"))
print(find_library("crypt"))
if __name__ == "__main__":
test()