bpo-34424: Handle different policy.linesep lengths correctly. (#8803)

This commit is contained in:
Jens Troeger 2019-05-14 11:07:39 +10:00 committed by R. David Murray
parent 8da5ebe11e
commit 45b2f8893c
3 changed files with 25 additions and 1 deletions

View file

@ -2625,7 +2625,7 @@ def _refold_parse_tree(parse_tree, *, policy):
want_encoding = False
last_ew = None
if part.syntactic_break:
encoded_part = part.fold(policy=policy)[:-1] # strip nl
encoded_part = part.fold(policy=policy)[:-len(policy.linesep)]
if policy.linesep not in encoded_part:
# It fits on a single line
if len(encoded_part) > maxlen - len(lines[-1]):