mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
452bf519a7
commit
be19ed77dd
331 changed files with 2567 additions and 2648 deletions
|
@ -80,7 +80,7 @@ class Generator:
|
|||
ufrom = msg.get_unixfrom()
|
||||
if not ufrom:
|
||||
ufrom = 'From nobody ' + time.ctime(time.time())
|
||||
print >> self._fp, ufrom
|
||||
print(ufrom, file=self._fp)
|
||||
self._write(msg)
|
||||
|
||||
def clone(self, fp):
|
||||
|
@ -140,13 +140,13 @@ class Generator:
|
|||
|
||||
def _write_headers(self, msg):
|
||||
for h, v in msg.items():
|
||||
print >> self._fp, '%s:' % h,
|
||||
print('%s:' % h, end=' ', file=self._fp)
|
||||
if self._maxheaderlen == 0:
|
||||
# Explicit no-wrapping
|
||||
print >> self._fp, v
|
||||
print(v, file=self._fp)
|
||||
elif isinstance(v, Header):
|
||||
# Header instances know what to do
|
||||
print >> self._fp, v.encode()
|
||||
print(v.encode(), file=self._fp)
|
||||
elif _is8bitstring(v):
|
||||
# If we have raw 8bit data in a byte string, we have no idea
|
||||
# what the encoding is. There is no safe way to split this
|
||||
|
@ -154,14 +154,14 @@ class Generator:
|
|||
# ascii split, but if it's multibyte then we could break the
|
||||
# string. There's no way to know so the least harm seems to
|
||||
# be to not split the string and risk it being too long.
|
||||
print >> self._fp, v
|
||||
print(v, file=self._fp)
|
||||
else:
|
||||
# Header's got lots of smarts, so use it.
|
||||
print >> self._fp, Header(
|
||||
print(Header(
|
||||
v, maxlinelen=self._maxheaderlen,
|
||||
header_name=h, continuation_ws='\t').encode()
|
||||
header_name=h, continuation_ws='\t').encode(), file=self._fp)
|
||||
# A blank line always separates headers from body
|
||||
print >> self._fp
|
||||
print(file=self._fp)
|
||||
|
||||
#
|
||||
# Handlers for writing types and subtypes
|
||||
|
@ -215,9 +215,9 @@ class Generator:
|
|||
msg.set_boundary(boundary)
|
||||
# If there's a preamble, write it out, with a trailing CRLF
|
||||
if msg.preamble is not None:
|
||||
print >> self._fp, msg.preamble
|
||||
print(msg.preamble, file=self._fp)
|
||||
# dash-boundary transport-padding CRLF
|
||||
print >> self._fp, '--' + boundary
|
||||
print('--' + boundary, file=self._fp)
|
||||
# body-part
|
||||
if msgtexts:
|
||||
self._fp.write(msgtexts.pop(0))
|
||||
|
@ -226,13 +226,13 @@ class Generator:
|
|||
# --> CRLF body-part
|
||||
for body_part in msgtexts:
|
||||
# delimiter transport-padding CRLF
|
||||
print >> self._fp, '\n--' + boundary
|
||||
print('\n--' + boundary, file=self._fp)
|
||||
# body-part
|
||||
self._fp.write(body_part)
|
||||
# close-delimiter transport-padding
|
||||
self._fp.write('\n--' + boundary + '--')
|
||||
if msg.epilogue is not None:
|
||||
print >> self._fp
|
||||
print(file=self._fp)
|
||||
self._fp.write(msg.epilogue)
|
||||
|
||||
def _handle_message_delivery_status(self, msg):
|
||||
|
@ -308,12 +308,12 @@ class DecodedGenerator(Generator):
|
|||
for part in msg.walk():
|
||||
maintype = part.get_content_maintype()
|
||||
if maintype == 'text':
|
||||
print >> self, part.get_payload(decode=True)
|
||||
print(part.get_payload(decode=True), file=self)
|
||||
elif maintype == 'multipart':
|
||||
# Just skip this
|
||||
pass
|
||||
else:
|
||||
print >> self, self._fmt % {
|
||||
print(self._fmt % {
|
||||
'type' : part.get_content_type(),
|
||||
'maintype' : part.get_content_maintype(),
|
||||
'subtype' : part.get_content_subtype(),
|
||||
|
@ -322,7 +322,7 @@ class DecodedGenerator(Generator):
|
|||
'[no description]'),
|
||||
'encoding' : part.get('Content-Transfer-Encoding',
|
||||
'[no encoding]'),
|
||||
}
|
||||
}, file=self)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue