Continue accelerating the 2to3 step (remove fix_print).

This commit is contained in:
Valentin Lorentz 2014-01-20 15:31:09 +01:00
parent 529b8f8d99
commit c1c23f66f4
13 changed files with 61 additions and 58 deletions

View File

@ -89,9 +89,9 @@ class MathTestCase(PluginTestCase):
self.assertError('base 4 4') self.assertError('base 4 4')
self.assertError('base 10 12 A') self.assertError('base 10 12 A')
print print()
print "If we have not fixed a bug with Math.base, the following ", print("If we have not fixed a bug with Math.base, the following ")
print "tests will hang the test-suite." print("tests will hang the test-suite.")
self.assertRegexp('base 2 10 [base 10 2 -12]', '-12') self.assertRegexp('base 2 10 [base 10 2 -12]', '-12')
self.assertRegexp('base 16 2 [base 2 16 -110101]', '-110101') self.assertRegexp('base 16 2 [base 2 16 -110101]', '-110101')

View File

@ -131,8 +131,8 @@ class MiscTestCase(ChannelPluginTestCase):
if network: if network:
def testVersion(self): def testVersion(self):
print '*** This test should start passing when we have our '\ print('*** This test should start passing when we have our '\
'threaded issues resolved.' 'threaded issues resolved.')
self.assertNotError('version') self.assertNotError('version')
def testSource(self): def testSource(self):

View File

@ -48,10 +48,10 @@ class NewsTestCase(ChannelPluginTestCase):
self.assertRegexp('news', 'subject.*subject2') self.assertRegexp('news', 'subject.*subject2')
self.assertNotError('add 5 subject3: foo3') self.assertNotError('add 5 subject3: foo3')
self.assertRegexp('news', 'subject3') self.assertRegexp('news', 'subject3')
print print()
print 'Sleeping to expire the news item (testAddnews)' print('Sleeping to expire the news item (testAddnews)')
time.sleep(6) time.sleep(6)
print 'Done sleeping.' print('Done sleeping.')
self.assertNotRegexp('news', 'subject3') self.assertNotRegexp('news', 'subject3')
def testNews(self): def testNews(self):
@ -77,10 +77,10 @@ class NewsTestCase(ChannelPluginTestCase):
self.assertRegexp('old', 'No old news') self.assertRegexp('old', 'No old news')
self.assertNotError('add 5 foo: bar') self.assertNotError('add 5 foo: bar')
self.assertRegexp('old', 'No old news') self.assertRegexp('old', 'No old news')
print print()
print 'Sleeping to expire the news item (testOldnews)' print('Sleeping to expire the news item (testOldnews)')
time.sleep(6) time.sleep(6)
print 'Done sleeping.' print('Done sleeping.')
self.assertNotError('old') self.assertNotError('old')

View File

@ -65,9 +65,9 @@ class WebTestCase(ChannelPluginTestCase):
# part of it. # part of it.
self.assertRegexp('title http://www.n-e-r-d.com/', 'N.*E.*R.*D') self.assertRegexp('title http://www.n-e-r-d.com/', 'N.*E.*R.*D')
# Checks that the parser doesn't hang on invalid tags # Checks that the parser doesn't hang on invalid tags
print print()
print "If we have not fixed a bug with the parser, the following", print("If we have not fixed a bug with the parser, the following")
print "test will hang the test-suite." print("test will hang the test-suite.")
self.assertNotError( self.assertNotError(
'title http://www.youtube.com/watch?v=x4BtiqPN4u8') 'title http://www.youtube.com/watch?v=x4BtiqPN4u8')

View File

@ -155,7 +155,7 @@ try:
'fix_itertools', 'fix_itertools_imports', 'fix_long', 'fix_itertools', 'fix_itertools_imports', 'fix_long',
'fix_map', 'fix_metaclass', 'fix_methodattrs', 'fix_map', 'fix_metaclass', 'fix_methodattrs',
'fix_numliterals', 'fix_numliterals',
'fix_print', 'fix_raise', 'fix_raise',
'fix_reduce', 'fix_renames', 'fix_repr', 'fix_reduce', 'fix_renames', 'fix_repr',
'fix_set_literal', 'fix_standarderror', 'fix_sys_exc', 'fix_set_literal', 'fix_standarderror', 'fix_sys_exc',
'fix_throw', 'fix_tuple_params', 'fix_types', 'fix_throw', 'fix_tuple_params', 'fix_types',

View File

@ -1144,9 +1144,9 @@ class DefaultCapabilities(registry.SpaceSeparatedListOfStrings):
def setValue(self, v, allowDefaultOwner=conf.allowDefaultOwner): def setValue(self, v, allowDefaultOwner=conf.allowDefaultOwner):
registry.SpaceSeparatedListOfStrings.setValue(self, v) registry.SpaceSeparatedListOfStrings.setValue(self, v)
if '-owner' not in self.value and not allowDefaultOwner: if '-owner' not in self.value and not allowDefaultOwner:
print '*** You must run supybot with the --allow-default-owner' print('*** You must run supybot with the --allow-default-owner')
print '*** option in order to allow a default capability of owner.' print('*** option in order to allow a default capability of owner.')
print '*** Don\'t do that, it\'s dumb.' print('*** Don\'t do that, it\'s dumb.')
self.value.add('-owner') self.value.add('-owner')
conf.registerGlobalValue(conf.supybot, 'capabilities', conf.registerGlobalValue(conf.supybot, 'capabilities',

View File

@ -36,6 +36,7 @@ work in an IRC-case-insensitive fashion), and numerous other things.
""" """
from __future__ import division from __future__ import division
from __future__ import print_function
import re import re
import sys import sys
@ -51,7 +52,7 @@ from itertools import imap
def debug(s, *args): def debug(s, *args):
"""Prints a debug string. Most likely replaced by our logging debug.""" """Prints a debug string. Most likely replaced by our logging debug."""
print '***', s % args print('***', s % args)
userHostmaskRe = re.compile(r'^\S+!\S+@\S+$') userHostmaskRe = re.compile(r'^\S+!\S+@\S+$')
def isUserHostmask(s): def isUserHostmask(s):

View File

@ -95,9 +95,9 @@ class StdoutStreamHandler(logging.StreamHandler):
# We check for ERROR there because otherwise, tracebacks (which are # We check for ERROR there because otherwise, tracebacks (which are
# already wrapped by Python itself) wrap oddly. # already wrapped by Python itself) wrap oddly.
if not isinstance(record.levelname, basestring): if not isinstance(record.levelname, basestring):
print record print(record)
print record.levelname print(record.levelname)
print utils.stackTrace() print(utils.stackTrace())
prefixLen = len(record.levelname) + 1 # ' ' prefixLen = len(record.levelname) + 1 # ' '
s = textwrap.fill(s, width=78, subsequent_indent=' '*prefixLen) s = textwrap.fill(s, width=78, subsequent_indent=' '*prefixLen)
s.rstrip('\r\n') s.rstrip('\r\n')

View File

@ -29,7 +29,7 @@
"""Handles interactive questions; useful for wizards and whatnot.""" """Handles interactive questions; useful for wizards and whatnot."""
from __future__ import print_function
import sys import sys
import textwrap import textwrap
@ -44,8 +44,8 @@ useBold = False
def output(s, unformatted=True, fd=sys.stdout): def output(s, unformatted=True, fd=sys.stdout):
if unformatted: if unformatted:
s = textwrap.fill(utils.str.normalizeWhitespace(s), width=65) s = textwrap.fill(utils.str.normalizeWhitespace(s), width=65)
print >>fd, s print(s, file=fd)
print >>fd print('', file=fd)
def expect(prompt, possibilities, recursed=False, default=None, def expect(prompt, possibilities, recursed=False, default=None,
acceptEmpty=False, fd=sys.stdout): acceptEmpty=False, fd=sys.stdout):
@ -75,13 +75,13 @@ def expect(prompt, possibilities, recursed=False, default=None,
prompt = prompt.strip() + ' ' prompt = prompt.strip() + ' '
if useBold: if useBold:
prompt += ansi.RESET prompt += ansi.RESET
print >>fd, ansi.BOLD, print(ansi.BOLD, end=' ', file=fd)
if sys.version_info[0] >= 3: if sys.version_info[0] >= 3:
s = input(prompt) s = input(prompt)
else: else:
s = raw_input(prompt) s = raw_input(prompt)
s = s.strip() s = s.strip()
print >>fd print(file=fd)
if possibilities: if possibilities:
if s in possibilities: if s in possibilities:
return s return s
@ -143,7 +143,7 @@ def getpass(prompt=None, secondPrompt=None):
output(_('Passwords don\'t match.')) output(_('Passwords don\'t match.'))
else: else:
break break
print print('')
return password return password

View File

@ -42,11 +42,11 @@ _ = i18n.PluginInternationalization()
def error(s): def error(s):
"""Replace me with something better from another module!""" """Replace me with something better from another module!"""
print '***', s print('***', s)
def exception(s): def exception(s):
"""Ditto!""" """Ditto!"""
print '***', s, 'A bad exception.' print('***', s, 'A bad exception.')
class RegistryException(Exception): class RegistryException(Exception):
pass pass

View File

@ -31,13 +31,13 @@ class shlex:
self.filestack = [] self.filestack = []
self.source = None self.source = None
if self.debug: if self.debug:
print 'shlex: reading from %s, line %d' \ print('shlex: reading from %s, line %d' \
% (self.instream, self.lineno) % (self.instream, self.lineno))
def push_token(self, tok): def push_token(self, tok):
"Push a token onto the stack popped by the get_token method" "Push a token onto the stack popped by the get_token method"
if self.debug >= 1: if self.debug >= 1:
print "shlex: pushing token " + `tok` print("shlex: pushing token " + `tok`)
self.pushback = [tok] + self.pushback self.pushback = [tok] + self.pushback
def push_source(self, newstream, newfile=None): def push_source(self, newstream, newfile=None):
@ -48,9 +48,9 @@ class shlex:
self.lineno = 1 self.lineno = 1
if self.debug: if self.debug:
if newfile is not None: if newfile is not None:
print 'shlex: pushing to file %s' % (self.infile,) print('shlex: pushing to file %s' % (self.infile,))
else: else:
print 'shlex: pushing to stream %s' % (self.instream,) print('shlex: pushing to stream %s' % (self.instream,))
def pop_source(self): def pop_source(self):
"Pop the input source stack." "Pop the input source stack."
@ -58,8 +58,8 @@ class shlex:
(self.infile, self.instream, self.lineno) = self.filestack[0] (self.infile, self.instream, self.lineno) = self.filestack[0]
self.filestack = self.filestack[1:] self.filestack = self.filestack[1:]
if self.debug: if self.debug:
print 'shlex: popping to %s, line %d' \ print('shlex: popping to %s, line %d' \
% (self.instream, self.lineno) % (self.instream, self.lineno))
self.state = ' ' self.state = ' '
def get_token(self): def get_token(self):
@ -68,7 +68,7 @@ class shlex:
tok = self.pushback[0] tok = self.pushback[0]
self.pushback = self.pushback[1:] self.pushback = self.pushback[1:]
if self.debug >= 1: if self.debug >= 1:
print "shlex: popping token " + `tok` print("shlex: popping token " + `tok`)
return tok return tok
# No pushback. Get a token. # No pushback. Get a token.
raw = self.read_token() raw = self.read_token()
@ -89,9 +89,9 @@ class shlex:
# Neither inclusion nor EOF # Neither inclusion nor EOF
if self.debug >= 1: if self.debug >= 1:
if raw: if raw:
print "shlex: token=" + `raw` print("shlex: token=" + `raw`)
else: else:
print "shlex: token=EOF" print("shlex: token=EOF")
return raw return raw
def read_token(self): def read_token(self):
@ -101,8 +101,8 @@ class shlex:
if nextchar == '\n': if nextchar == '\n':
self.lineno = self.lineno + 1 self.lineno = self.lineno + 1
if self.debug >= 3: if self.debug >= 3:
print "shlex: in state", repr(self.state), \ print("shlex: in state", repr(self.state), \
"I see character:", repr(nextchar) "I see character:", repr(nextchar))
if self.state is None: if self.state is None:
self.token = '' # past end of file self.token = '' # past end of file
break break
@ -112,7 +112,7 @@ class shlex:
break break
elif nextchar in self.whitespace: elif nextchar in self.whitespace:
if self.debug >= 2: if self.debug >= 2:
print "shlex: I see whitespace in whitespace state" print("shlex: I see whitespace in whitespace state")
if self.token: if self.token:
break # emit current token break # emit current token
else: else:
@ -147,7 +147,7 @@ class shlex:
self.backslash = False self.backslash = False
elif not nextchar: # end of file elif not nextchar: # end of file
if self.debug >= 2: if self.debug >= 2:
print "shlex: I see EOF in quotes state" print("shlex: I see EOF in quotes state")
# XXX what error should be raised here? # XXX what error should be raised here?
raise ValueError, "No closing quotation" raise ValueError, "No closing quotation"
elif self.state == 'a': elif self.state == 'a':
@ -156,7 +156,7 @@ class shlex:
break break
elif nextchar in self.whitespace: elif nextchar in self.whitespace:
if self.debug >= 2: if self.debug >= 2:
print "shlex: I see whitespace in word state" print("shlex: I see whitespace in word state")
self.state = ' ' self.state = ' '
if self.token: if self.token:
break # emit current token break # emit current token
@ -170,7 +170,7 @@ class shlex:
else: else:
self.pushback = [nextchar] + self.pushback self.pushback = [nextchar] + self.pushback
if self.debug >= 2: if self.debug >= 2:
print "shlex: I see punctuation in word state" print("shlex: I see punctuation in word state")
self.state = ' ' self.state = ' '
if self.token: if self.token:
break # emit current token break # emit current token
@ -180,9 +180,9 @@ class shlex:
self.token = '' self.token = ''
if self.debug > 1: if self.debug > 1:
if result: if result:
print "shlex: raw token=" + `result` print("shlex: raw token=" + `result`)
else: else:
print "shlex: raw token=EOF" print("shlex: raw token=EOF")
return result return result
def sourcehook(self, newfile): def sourcehook(self, newfile):
@ -213,6 +213,6 @@ if __name__ == '__main__':
while True: while True:
tt = lexer.get_token() tt = lexer.get_token()
if tt: if tt:
print "Token: " + repr(tt) print("Token: " + repr(tt))
else: else:
break break

View File

@ -147,8 +147,8 @@ class PluginTestCase(SupyTestCase):
for cb in self.irc.callbacks: for cb in self.irc.callbacks:
cbModule = sys.modules[cb.__class__.__module__] cbModule = sys.modules[cb.__class__.__module__]
if hasattr(cbModule, 'deprecated') and cbModule.deprecated: if hasattr(cbModule, 'deprecated') and cbModule.deprecated:
print print('')
print 'Ignored, %s is deprecated.' % cb.name() print('Ignored, %s is deprecated.' % cb.name())
run = False run = False
if run: if run:
originalRunTest() originalRunTest()
@ -238,7 +238,7 @@ class PluginTestCase(SupyTestCase):
if timeout is None: if timeout is None:
timeout = self.timeout timeout = self.timeout
if self.myVerbose: if self.myVerbose:
print # Extra newline, so it's pretty. print('') # Extra newline, so it's pretty.
prefixChars = conf.supybot.reply.whenAddressedBy.chars() prefixChars = conf.supybot.reply.whenAddressedBy.chars()
if not usePrefixChar and query[0] in prefixChars: if not usePrefixChar and query[0] in prefixChars:
query = query[1:] query = query[1:]
@ -246,7 +246,7 @@ class PluginTestCase(SupyTestCase):
query = query.encode('utf8') # unicode->str query = query.encode('utf8') # unicode->str
msg = ircmsgs.privmsg(to, query, prefix=frm) msg = ircmsgs.privmsg(to, query, prefix=frm)
if self.myVerbose: if self.myVerbose:
print 'Feeding: %r' % msg print('Feeding: %r' % msg)
self.irc.feedMsg(msg) self.irc.feedMsg(msg)
fed = time.time() fed = time.time()
response = self.irc.takeMsg() response = self.irc.takeMsg()
@ -255,7 +255,7 @@ class PluginTestCase(SupyTestCase):
drivers.run() drivers.run()
response = self.irc.takeMsg() response = self.irc.takeMsg()
if self.myVerbose: if self.myVerbose:
print 'Response: %r' % response print('Response: %r' % response)
return response return response
def getMsg(self, query, **kwargs): def getMsg(self, query, **kwargs):
@ -433,7 +433,7 @@ class ChannelPluginTestCase(PluginTestCase):
if timeout is None: if timeout is None:
timeout = self.timeout timeout = self.timeout
if self.myVerbose: if self.myVerbose:
print # Newline, just like PluginTestCase. print('') # Newline, just like PluginTestCase.
prefixChars = conf.supybot.reply.whenAddressedBy.chars() prefixChars = conf.supybot.reply.whenAddressedBy.chars()
if query[0] not in prefixChars and usePrefixChar: if query[0] not in prefixChars and usePrefixChar:
query = prefixChars[0] + query query = prefixChars[0] + query
@ -441,7 +441,7 @@ class ChannelPluginTestCase(PluginTestCase):
query = query.encode('utf8') # unicode->str query = query.encode('utf8') # unicode->str
msg = ircmsgs.privmsg(to, query, prefix=frm) msg = ircmsgs.privmsg(to, query, prefix=frm)
if self.myVerbose: if self.myVerbose:
print 'Feeding: %r' % msg print('Feeding: %r' % msg)
self.irc.feedMsg(msg) self.irc.feedMsg(msg)
fed = time.time() fed = time.time()
response = self.irc.takeMsg() response = self.irc.takeMsg()
@ -466,7 +466,7 @@ class ChannelPluginTestCase(PluginTestCase):
else: else:
ret = None ret = None
if self.myVerbose: if self.myVerbose:
print 'Returning: %r' % ret print('Returning: %r' % ret)
return ret return ret
def feedMsg(self, query, to=None, frm=None, private=False): def feedMsg(self, query, to=None, frm=None, private=False):

View File

@ -28,6 +28,8 @@
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
### ###
from __future__ import print_function
import os import os
import sys import sys
import ast import ast
@ -345,7 +347,7 @@ def callTracer(fd=None, basename=True):
filename = code.co_filename filename = code.co_filename
if basename: if basename:
filename = os.path.basename(filename) filename = os.path.basename(filename)
print >>fd, '%s: %s(%s)' % (filename, funcname, lineno) print('%s: %s(%s)' % (filename, funcname, lineno), file=fd)
return tracer return tracer
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: