diff options
author | Guido van Rossum <guido@python.org> | 2007-02-09 05:37:30 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-02-09 05:37:30 (GMT) |
commit | be19ed77ddb047e02fe94d142181062af6d99dcc (patch) | |
tree | 70f214e06554046fcccbadeb78665f25e07ce965 /Lib/cgi.py | |
parent | 452bf519a70c3db0e7f0d2540b1bfb07d9085583 (diff) | |
download | cpython-be19ed77ddb047e02fe94d142181062af6d99dcc.zip cpython-be19ed77ddb047e02fe94d142181062af6d99dcc.tar.gz cpython-be19ed77ddb047e02fe94d142181062af6d99dcc.tar.bz2 |
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.)
Diffstat (limited to 'Lib/cgi.py')
-rwxr-xr-x | Lib/cgi.py | 70 |
1 files changed, 35 insertions, 35 deletions
@@ -901,8 +901,8 @@ def test(environ=os.environ): the script in HTML form. """ - print "Content-type: text/html" - print + print("Content-type: text/html") + print() sys.stderr = sys.stdout try: form = FieldStorage() # Replace with other classes to test those @@ -915,12 +915,12 @@ def test(environ=os.environ): exec("testing print_exception() -- <I>italics?</I>") def g(f=f): f() - print "<H3>What follows is a test, not an actual exception:</H3>" + print("<H3>What follows is a test, not an actual exception:</H3>") g() except: print_exception() - print "<H1>Second try with a small maxlen...</H1>" + print("<H1>Second try with a small maxlen...</H1>") global maxlen maxlen = 50 @@ -937,67 +937,67 @@ def print_exception(type=None, value=None, tb=None, limit=None): if type is None: type, value, tb = sys.exc_info() import traceback - print - print "<H3>Traceback (most recent call last):</H3>" + print() + print("<H3>Traceback (most recent call last):</H3>") list = traceback.format_tb(tb, limit) + \ traceback.format_exception_only(type, value) - print "<PRE>%s<B>%s</B></PRE>" % ( + print("<PRE>%s<B>%s</B></PRE>" % ( escape("".join(list[:-1])), escape(list[-1]), - ) + )) del tb def print_environ(environ=os.environ): """Dump the shell environment as HTML.""" keys = environ.keys() keys.sort() - print - print "<H3>Shell Environment:</H3>" - print "<DL>" + print() + print("<H3>Shell Environment:</H3>") + print("<DL>") for key in keys: - print "<DT>", escape(key), "<DD>", escape(environ[key]) - print "</DL>" - print + print("<DT>", escape(key), "<DD>", escape(environ[key])) + print("</DL>") + print() def print_form(form): """Dump the contents of a form as HTML.""" keys = form.keys() keys.sort() - print - print "<H3>Form Contents:</H3>" + print() + print("<H3>Form Contents:</H3>") if not keys: - print "<P>No form fields." - print "<DL>" + print("<P>No form fields.") + print("<DL>") for key in keys: - print "<DT>" + escape(key) + ":", + print("<DT>" + escape(key) + ":", end=' ') value = form[key] - print "<i>" + escape(repr(type(value))) + "</i>" - print "<DD>" + escape(repr(value)) - print "</DL>" - print + print("<i>" + escape(repr(type(value))) + "</i>") + print("<DD>" + escape(repr(value))) + print("</DL>") + print() def print_directory(): """Dump the current directory as HTML.""" - print - print "<H3>Current Working Directory:</H3>" + print() + print("<H3>Current Working Directory:</H3>") try: pwd = os.getcwd() except os.error as msg: - print "os.error:", escape(str(msg)) + print("os.error:", escape(str(msg))) else: - print escape(pwd) - print + print(escape(pwd)) + print() def print_arguments(): - print - print "<H3>Command Line Arguments:</H3>" - print - print sys.argv - print + print() + print("<H3>Command Line Arguments:</H3>") + print() + print(sys.argv) + print() def print_environ_usage(): """Dump a list of environment variables used by CGI as HTML.""" - print """ + print(""" <H3>These environment variables could have been set:</H3> <UL> <LI>AUTH_TYPE @@ -1036,7 +1036,7 @@ environment as well. Here are some common variable names: <LI>HTTP_REFERER <LI>HTTP_USER_AGENT </UL> -""" +""") # Utilities |