8000 [email] bpo-29478: Fix passing max_line_length=None from Compat32 policy by mircea-cosbuc · Pull Request #595 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[email] bpo-29478: Fix passing max_line_length=None from Compat32 policy #595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Lib/email/_policybase.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,12 @@ def _fold(self, name, value, sanitize):
# 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)

Expand Down
7 changes: 7 additions & 0 deletions Lib/test/test_email/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ def test_set_mangle_from_via_policy(self):
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):

Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ Garrett Cooper
Greg Copeland
Ian Cordasco
Aldo Cortesi
Mircea Cosbuc
David Costanzo
Scott Cotton
Greg Couch
Expand Down
3 changes: 3 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ Core and Builtins

- bpo-29546: Improve from-import error message with location

- bpo-29478: If max_line_length=None is specified while using the Compat32 policy,
it is no longer ignored. Patch by Mircea Cosbuc.

- Issue #29319: Prevent RunMainFromImporter overwriting sys.path[0].

- Issue #29337: Fixed possible BytesWarning when compare the code objects.
Expand Down
0