diff options
author | Mariatta <Mariatta@users.noreply.github.com> | 2017-06-16 02:38:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-16 02:38:12 (GMT) |
commit | 820b71464c2c0e8cca1abfb5dfe47fa7f7ffec75 (patch) | |
tree | b694efafd9e79469c8b08b31483c5f6825f299bb | |
parent | 0b13f58497d3a36d062c3b3b827abb05db5afbc1 (diff) | |
download | cpython-820b71464c2c0e8cca1abfb5dfe47fa7f7ffec75.zip cpython-820b71464c2c0e8cca1abfb5dfe47fa7f7ffec75.tar.gz cpython-820b71464c2c0e8cca1abfb5dfe47fa7f7ffec75.tar.bz2 |
[email] bpo-29478: Fix passing max_line_length=None from Compat32 policy (GH-595) (GH-2234)
If max_line_length=None is specified while using the Compat32 policy,
it is no longer ignored..
(cherry picked from commit b459f7482612d340b88b62edc024628595ec6337)
-rw-r--r-- | Lib/email/_policybase.py | 8 | ||||
-rw-r--r-- | Lib/test/test_email/test_generator.py | 7 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
4 files changed, 17 insertions, 2 deletions
diff --git a/Lib/email/_policybase.py b/Lib/email/_policybase.py index c0d98a4..7326d3a 100644 --- a/Lib/email/_policybase.py +++ b/Lib/email/_policybase.py @@ -357,8 +357,12 @@ class Compat32(Policy): # Assume it is a Header-like object. h = value if h is not None: - parts.append(h.encode(linesep=self.linesep, - maxlinelen=self.max_line_length)) + # The Header class interprets a value of None for maxlinelen as the + # default value of 78, as recommended by RFC 2822. + maxlinelen = 0 + if self.max_line_length is not None: + maxlinelen = self.max_line_length + parts.append(h.encode(linesep=self.linesep, maxlinelen=maxlinelen)) parts.append(self.linesep) return ''.join(parts) diff --git a/Lib/test/test_email/test_generator.py b/Lib/test/test_email/test_generator.py index b1cbce2..226c5f9 100644 --- a/Lib/test/test_email/test_generator.py +++ b/Lib/test/test_email/test_generator.py @@ -162,6 +162,13 @@ class TestGeneratorBase: g.flatten(msg) self.assertEqual(s.getvalue(), self.typ(expected)) + def test_compat32_max_line_length_does_not_fold_when_none(self): + msg = self.msgmaker(self.typ(self.refold_long_expected[0])) + s = self.ioclass() + g = self.genclass(s, policy=policy.compat32.clone(max_line_length=None)) + g.flatten(msg) + self.assertEqual(s.getvalue(), self.typ(self.refold_long_expected[0])) + class TestGenerator(TestGeneratorBase, TestEmailBase): @@ -304,6 +304,7 @@ Garrett Cooper Greg Copeland Ian Cordasco Aldo Cortesi +Mircea Cosbuc David Costanzo Scott Cotton Greg Couch @@ -48,6 +48,9 @@ Core and Builtins - Issue #29337: Fixed possible BytesWarning when compare the code objects. Warnings could be emitted at compile time. +- bpo-29478: If max_line_length=None is specified while using the Compat32 policy, + it is no longer ignored. Patch by Mircea Cosbuc. + Extension Modules ----------------- |