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/email | |
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/email')
-rw-r--r-- | Lib/email/generator.py | 30 | ||||
-rw-r--r-- | Lib/email/iterators.py | 6 | ||||
-rw-r--r-- | Lib/email/test/test_email.py | 2 | ||||
-rw-r--r-- | Lib/email/test/test_email_renamed.py | 2 |
4 files changed, 20 insertions, 20 deletions
diff --git a/Lib/email/generator.py b/Lib/email/generator.py index ed832a3..4f3fea4 100644 --- a/Lib/email/generator.py +++ b/Lib/email/generator.py @@ -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) diff --git a/Lib/email/iterators.py b/Lib/email/iterators.py index e99f228..4f2c84c 100644 --- a/Lib/email/iterators.py +++ b/Lib/email/iterators.py @@ -63,11 +63,11 @@ def _structure(msg, fp=None, level=0, include_default=False): if fp is None: fp = sys.stdout tab = ' ' * (level * 4) - print >> fp, tab + msg.get_content_type(), + print(tab + msg.get_content_type(), end=' ', file=fp) if include_default: - print >> fp, '[%s]' % msg.get_default_type() + print('[%s]' % msg.get_default_type(), file=fp) else: - print >> fp + print(file=fp) if msg.is_multipart(): for subpart in msg.get_payload(): _structure(subpart, fp, level+1, include_default) diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index 8127ef0..0a25a67 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -56,7 +56,7 @@ class TestEmailBase(unittest.TestCase): ssecond = str(second) diff = difflib.ndiff(sfirst.splitlines(), ssecond.splitlines()) fp = StringIO() - print >> fp, NL, NL.join(diff) + print(NL, NL.join(diff), file=fp) raise self.failureException, fp.getvalue() def _msgobj(self, filename): diff --git a/Lib/email/test/test_email_renamed.py b/Lib/email/test/test_email_renamed.py index ce685c5..532b146 100644 --- a/Lib/email/test/test_email_renamed.py +++ b/Lib/email/test/test_email_renamed.py @@ -57,7 +57,7 @@ class TestEmailBase(unittest.TestCase): ssecond = str(second) diff = difflib.ndiff(sfirst.splitlines(), ssecond.splitlines()) fp = StringIO() - print >> fp, NL, NL.join(diff) + print(NL, NL.join(diff), file=fp) raise self.failureException, fp.getvalue() def _msgobj(self, filename): |