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.)
diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py
index 6f0e0d8..bbcf292 100644
--- a/Lib/distutils/command/bdist_rpm.py
+++ b/Lib/distutils/command/bdist_rpm.py
@@ -267,11 +267,11 @@
def run (self):
if DEBUG:
- print "before _get_package_data():"
- print "vendor =", self.vendor
- print "packager =", self.packager
- print "doc_files =", self.doc_files
- print "changelog =", self.changelog
+ print("before _get_package_data():")
+ print("vendor =", self.vendor)
+ print("packager =", self.packager)
+ print("doc_files =", self.doc_files)
+ print("changelog =", self.changelog)
# make directories
if self.spec_only:
diff --git a/Lib/distutils/command/config.py b/Lib/distutils/command/config.py
index 520c1b0..4246569 100644
--- a/Lib/distutils/command/config.py
+++ b/Lib/distutils/command/config.py
@@ -359,9 +359,9 @@
def dump_file (filename, head=None):
if head is None:
- print filename + ":"
+ print(filename + ":")
else:
- print head
+ print(head)
file = open(filename)
sys.stdout.write(file.read())
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index 453151d..fd5d6d1 100644
--- a/Lib/distutils/command/install.py
+++ b/Lib/distutils/command/install.py
@@ -292,7 +292,7 @@
if DEBUG:
from pprint import pprint
- print "config vars:"
+ print("config vars:")
pprint(self.config_vars)
# Expand "~" and configuration variables in the installation
@@ -347,7 +347,7 @@
def dump_dirs (self, msg):
if DEBUG:
from distutils.fancy_getopt import longopt_xlate
- print msg + ":"
+ print(msg + ":")
for opt in self.user_options:
opt_name = opt[0]
if opt_name[-1] == "=":
@@ -359,7 +359,7 @@
else:
opt_name = string.translate(opt_name, longopt_xlate)
val = getattr(self, opt_name)
- print " %s: %s" % (opt_name, val)
+ print(" %s: %s" % (opt_name, val))
def finalize_unix (self):
diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py
index cb9525a..48070ee 100644
--- a/Lib/distutils/command/register.py
+++ b/Lib/distutils/command/register.py
@@ -86,14 +86,14 @@
''' Fetch the list of classifiers from the server.
'''
response = urllib2.urlopen(self.repository+'?:action=list_classifiers')
- print response.read()
+ print(response.read())
def verify_metadata(self):
''' Send the metadata to the package index server to be checked.
'''
# send the info to the server and report the result
(code, result) = self.post_to_server(self.build_post_data('verify'))
- print 'Server response (%s): %s'%(code, result)
+ print('Server response (%s): %s'%(code, result))
def send_metadata(self):
''' Send the metadata to the package index server.
@@ -128,7 +128,7 @@
if os.environ.has_key('HOME'):
rc = os.path.join(os.environ['HOME'], '.pypirc')
if os.path.exists(rc):
- print 'Using PyPI login from %s'%rc
+ print('Using PyPI login from %s'%rc)
config = ConfigParser.ConfigParser()
config.read(rc)
username = config.get('server-login', 'username')
@@ -138,17 +138,17 @@
# get the user's login info
choices = '1 2 3 4'.split()
while choice not in choices:
- print '''We need to know who you are, so please choose either:
+ print('''We need to know who you are, so please choose either:
1. use your existing login,
2. register as a new user,
3. have the server generate a new password for you (and email it to you), or
4. quit
-Your selection [default 1]: ''',
+Your selection [default 1]: ''', end=' ')
choice = raw_input()
if not choice:
choice = '1'
elif choice not in choices:
- print 'Please choose one of the four options!'
+ print('Please choose one of the four options!')
if choice == '1':
# get the username and password
@@ -165,13 +165,13 @@
# send the info to the server and report the result
code, result = self.post_to_server(self.build_post_data('submit'),
auth)
- print 'Server response (%s): %s'%(code, result)
+ print('Server response (%s): %s'%(code, result))
# possibly save the login
if os.environ.has_key('HOME') and config is None and code == 200:
rc = os.path.join(os.environ['HOME'], '.pypirc')
- print 'I can store your PyPI login so future submissions will be faster.'
- print '(the login will be stored in %s)'%rc
+ print('I can store your PyPI login so future submissions will be faster.')
+ print('(the login will be stored in %s)'%rc)
choice = 'X'
while choice.lower() not in 'yn':
choice = raw_input('Save your login (y/N)?')
@@ -200,22 +200,22 @@
if data['password'] != data['confirm']:
data['password'] = ''
data['confirm'] = None
- print "Password and confirm don't match!"
+ print("Password and confirm don't match!")
while not data['email']:
data['email'] = raw_input(' EMail: ')
code, result = self.post_to_server(data)
if code != 200:
- print 'Server response (%s): %s'%(code, result)
+ print('Server response (%s): %s'%(code, result))
else:
- print 'You will receive an email shortly.'
- print 'Follow the instructions in it to complete registration.'
+ print('You will receive an email shortly.')
+ print('Follow the instructions in it to complete registration.')
elif choice == '3':
data = {':action': 'password_reset'}
data['email'] = ''
while not data['email']:
data['email'] = raw_input('Your email address: ')
code, result = self.post_to_server(data)
- print 'Server response (%s): %s'%(code, result)
+ print('Server response (%s): %s'%(code, result))
def build_post_data(self, action):
# figure the data to send - the metadata plus some additional
@@ -295,5 +295,5 @@
data = result.read()
result = 200, 'OK'
if self.show_response:
- print '-'*75, data, '-'*75
+ print('-'*75, data, '-'*75)
return result
diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py
index 7f96a47..438ae99 100644
--- a/Lib/distutils/command/upload.py
+++ b/Lib/distutils/command/upload.py
@@ -196,4 +196,4 @@
self.announce('Upload failed (%s): %s' % (r.status, r.reason),
log.ERROR)
if self.show_response:
- print '-'*75, r.read(), '-'*75
+ print('-'*75, r.read(), '-'*75)