8000 Fix most trivially-findable print statements. · python/cpython@be19ed7 · GitHub
[go: up one dir, main page]

Skip to content

Commit be19ed7

Browse files
committed
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.)
1 parent 452bf51 commit be19ed7

File tree

331 files changed

+2568
-2649
lines changed
  • wsgiref
  • xml
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    331 files changed

    +2568
    -2649
    lines changed

    Lib/BaseHTTPServer.py

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -570,7 +570,7 @@ def test(HandlerClass = BaseHTTPRequestHandler,
    570570
    httpd = ServerClass(server_address, HandlerClass)
    571571

    572572
    sa = httpd.socket.getsockname()
    573-
    print "Serving HTTP on", sa[0], "port", sa[1], "..."
    573+
    print("Serving HTTP on", sa[0], "port", sa[1], "...")
    574574
    httpd.serve_forever()
    575575

    576576

    Lib/Bastion.py

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -165,7 +165,7 @@ def total(self):
    165165
    print "accessible"
    166166
    \n"""
    167167
    exec(testcode)
    168-
    print '='*20, "Using rexec:", '='*20
    168+
    print('='*20, "Using rexec:", '='*20)
    169169
    import rexec
    170170
    r = rexec.RExec()
    171171
    m = r.add_module('__main__')

    Lib/Cookie.py

    Lines changed: 5 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -80,9 +80,9 @@
    8080
    >>> C = Cookie.SmartCookie()
    8181
    >>> C["rocky"] = "road"
    8282
    >>> C["rocky"]["path"] = "/cookie"
    83-
    >>> print C.output(header="Cookie:")
    83+
    >>> print(C.output(header="Cookie:"))
    8484
    Cookie: rocky=road; Path=/cookie
    85-
    >>> print C.output(attrs=[], header="Cookie:")
    85+
    >>> print(C.output(attrs=[], header="Cookie:"))
    8686
    Cookie: rocky=road
    8787
    8888
    The load() method of a Cookie extracts cookies from a string. In a
    @@ -100,7 +100,7 @@
    100100
    101101
    >>> C = Cookie.SmartCookie()
    102102
    >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
    103-
    >>> print C
    103+
    >>> print(C)
    104104
    Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"
    105105
    106106
    Each element of the Cookie also supports all of the RFC 2109
    @@ -110,7 +110,7 @@
    110110
    >>> C = Cookie.SmartCookie()
    111111
    >>> C["oreo"] = "doublestuff"
    112112
    >>> C["oreo"]["path"] = "/"
    113-
    >>> print C
    113+
    >>> print(C)
    114114
    Set-Cookie: oreo=doublestuff; Path=/
    115115
    116116
    Each dictionary element has a 'value' attribute, which gives you
    @@ -198,7 +198,7 @@
    198198
    fact, this simply returns a SmartCookie.
    199199
    200200
    >>> C = Cookie.Cookie()
    201-
    >>> print C.__class__.__name__
    201+
    >>> print(C.__class__.__name__)
    202202
    SmartCookie
    203203
    204204

    Lib/DocXMLRPCServer.py

    Lines changed: 3 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -270,9 +270,9 @@ def handle_get(self):
    270270

    271271
    response = self.generate_html_documentation()
    272272

    273-
    print 'Content-Type: text/html'
    274-
    print 'Content-Length: %d' % len(response)
    275-
    print
    273+
    print('Content-Type: text/html')
    274+
    print('Content-Length: %d' % len(response))
    275+
    print()
    276276
    sys.stdout.write(response)
    277277

    278278
    def __init__(self):

    Lib/SimpleXMLRPCServer.py

    Lines changed: 8 additions & 8 deletions
    Original file line numberDiff line numberDiff line change
    @@ -543,9 +543,9 @@ def handle_xmlrpc(self, request_text):
    543543

    544544
    response = self._marshaled_dispatch(request_text)
    545545

    546-
    print 'Content-Type: text/xml'
    547-
    print 'Content-Length: %d' % len(response)
    548-
    print
    546+
    print('Content-Type: text/xml')
    547+
    print('Content-Length: %d' % len(response))
    548+
    print()
    549549
    sys.stdout.write(response)
    550550

    551551
    def handle_get(self):
    @@ -565,10 +565,10 @@ def handle_get(self):
    565565
    'message' : message,
    566566
    'explain' : explain
    567567
    }
    568-
    print 'Status: %d %s' % (code, message)
    569-
    print 'Content-Type: text/html'
    570-
    print 'Content-Length: %d' % len(response)
    571-
    print
    568+
    print('Status: %d %s' % (code, message))
    569+
    print('Content-Type: text/html')
    570+
    print('Content-Length: %d' % len(response))
    571+
    print()
    572572
    sys.stdout.write(response)
    573573

    574574
    def handle_request(self, request_text = None):
    @@ -590,7 +590,7 @@ def handle_request(self, request_text = None):
    590590
    self.handle_xmlrpc(request_text)
    591591

    592592
    if __name__ == '__main__':
    593-
    print 'Running XML-RPC server on port 8000'
    593+
    print('Running XML-RPC server on port 8000')
    594594
    server = SimpleXMLRPCServer(("localhost", 8000))
    595595
    server.register_function(pow)
    596596
    server.register_function(lambda x,y: x+y, 'add')

    Lib/SocketServer.py

    Lines changed: 4 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -263,12 +263,12 @@ def handle_error(self, request, client_address):
    263263
    The default is to print a traceback and continue.
    264264
    265265
    """
    266-
    print '-'*40
    267-
    print 'Exception happened during processing of request from',
    268-
    print client_address
    266+
    print('-'*40)
    267+
    print('Exception happened during processing of request from', end=' ')
    268+
    print(client_address)
    269269
    import traceback
    270270
    traceback.print_exc() # XXX But this goes to stderr!
    271-
    print '-'*40
    271+
    print('-'*40)
    272272

    273273

    274274
    class TCPServer(BaseServer):

    Lib/StringIO.py

    Lines changed: 7 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -291,14 +291,14 @@ def test():
    291291
    if f.getvalue() != text:
    292292
    raise RuntimeError, 'write failed'
    293293
    length = f.tell()
    294-
    print 'File length =', length
    294+
    print('File length =', length)
    295295
    f.seek(len(lines[0]))
    296296
    f.write(lines[1])
    297297
    f.seek(0)
    298-
    print 'First line =', repr(f.readline())
    299-
    print 'Position =', f.tell()
    298+
    print('First line =', repr(f.readline()))
    299+
    print('Position =', f.tell())
    300300
    line = f.readline()
    301-
    print 'Second line =', repr(line)
    301+
    print('Second line =', repr(line))
    302302
    f.seek(-len(line), 1)
    303303
    line2 = f.read(len(line))
    304304
    if line != line2:
    @@ -310,13 +310,13 @@ def test():
    310310
    line2 = f.read()
    311311
    if line != line2:
    312312
    raise RuntimeError, 'bad result after seek back from EOF'
    313-
    print 'Read', len(list), 'more lines'
    314-
    print 'File length =', f.tell()
    313+
    print('Read', len(list), 'more lines')
    314+
    print('File length =', f.tell())
    315315
    if f.tell() != length:
    316316
    raise RuntimeError, 'bad length'
    317317
    f.truncate(length/2)
    318318
    f.seek(0, 2)
    319-
    print 'Truncated length =', f.tell()
    319+
    print('Truncated length =', f.tell())
    320320
    if f.tell() != length/2:
    321321
    raise RuntimeError, 'truncate did not adjust length'
    322322
    f.close()

    Lib/aifc.py

    Lines changed: 15 additions & 15 deletions
    Original file line numberDiff line numberDiff line change
    @@ -453,7 +453,7 @@ def _read_comm_chunk(self, chunk):
    453453
    kludge = 0
    454454
    if chunk.chunksize == 18:
    455455
    kludge = 1
    456-
    print 'Warning: bad COMM chunk size'
    456+
    print('Warning: bad COMM chunk size')
    457457
    chunk.chunksize = 23
    458458
    #DEBUG end
    459459
    self._comptype = chunk.read(4)
    @@ -518,11 +518,11 @@ def _readmark(self, chunk):
    518518
    # a position 0 and name ''
    519519
    self._markers.append((id, pos, name))
    520520
    except EOFError:
    521-
    print 'Warning: MARK chunk contains only',
    522-
    print len(self._markers),
    523-
    if len(self._markers) == 1: print 'marker',
    524-
    else: print 'markers',
    525-
    print 'instead of', nmarkers
    521+
    print('Warning: MARK chunk contains only', end=' ')
    522+
    print(len(self._markers), end=' ')
    523+
    if len(self._markers) == 1: print('marker', end=' ')
    524+
    else: print('markers', end=' ')
    525+
    print('instead of', nmarkers)
    526526

    527527
    class Aifc_write:
    528528
    # Variables used in this class:
    @@ -939,16 +939,16 @@ def open(f, mode=None):
    939939
    sys.argv.append('/usr/demos/data/audio/bach.aiff')
    940940
    fn = sys.argv[1]
    941941
    f = open(fn, 'r')
    942-
    print "Reading", fn
    943-
    print "nchannels =", f.getnchannels()
    944-
    print "nframes =", f.getnframes()
    945-
    print "sampwidth =", f.getsampwidth()
    946-
    print "framerate =", f.getframerate()
    947-
    print "comptype =", f.getcomptype()
    948-
    print "compname =", f.getcompname()
    942+
    print("Reading", fn)
    943+
    print("nchannels =", f.getnchannels())
    944+
    print("nframes =", f.getnframes())
    945+
    print("sampwidth =", f.getsampwidth())
    946+
    print("framerate =", f.getframerate())
    947+
    print("comptype =", f.getcomptype())
    948+
    print("compname =", f.getcompname())
    949949
    if sys.argv[2:]:
    950950
    gn = sys.argv[2]
    951-
    print "Writing", gn
    951+
    print("Writing", gn)
    952952
    g = open(gn, 'w')
    953953
    g.setparams(f.getparams())
    954954
    while 1:
    @@ -958,4 +958,4 @@ def open(f, mode=None):
    958958
    g.writeframes(data)
    959959
    g.close()
    960960
    f.close()
    961-
    print "Done."
    961+
    print("Done.")

    Lib/asyncore.py

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -373,7 +373,7 @@ def log(self, message):
    373373

    374374
    def log_info(self, message, type='info'):
    375375
    if __debug__ or type != 'info':
    376-
    print '%s: %s' % (type, message)
    376+
    print('%s: %s' % (type, message))
    377377

    378378
    def handle_read_event(self):
    379379
    if self.accepting:

    Lib/atexit.py

    Lines changed: 4 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -26,7 +26,7 @@ def _run_exitfuncs():
    2626
    exc_info = sys.exc_info()
    2727
    except:
    2828
    import traceback
    29-
    print >> sys.stderr, "Error in atexit._run_exitfuncs:"
    29+
    print("Error in atexit._run_exitfuncs:", file=sys.stderr)
    3030
    traceback.print_exc()
    3131
    exc_info = sys.exc_info()
    3232

    @@ -53,11 +53,11 @@ def register(func, *targs, **kargs):
    5353

    5454
    if __name__ == "__main__":
    5555
    def x1():
    56-
    print "running x1"
    56+
    print("running x1")
    5757
    def x2(n):
    58-
    print "running x2(%r)" % (n,)
    58+
    print("running x2(%r)" % (n,))
    5959
    def x3(n, kwd=None):
    60-
    print "running x3(%r, kwd=%r)" % (n, kwd)
    60+
    print("running x3(%r, kwd=%r)" % (n, kwd))
    6161

    6262
    register(x1)
    6363
    register(x2, 12)

    0 commit comments

    Comments
     (0)
    0