Kaydet (Commit) d81b796c authored tarafından Patrick Maupin's avatar Patrick Maupin

Stop triple quoting strings embedded in function calls

üst 5d004635
......@@ -479,10 +479,12 @@ class SourceGenerator(ExplicitNodeVisitor):
def visit_Str(self, node):
result = self.result
embedded = self.get__pp(node) > Precedence.Expr
# Cheesy way to force a flush
self.write('foo')
result.pop()
result.append(self.pretty_string(node.s, result))
result.append(self.pretty_string(node.s, embedded, result))
def visit_Bytes(self, node):
self.write(repr(node.s))
......
......@@ -76,7 +76,7 @@ def _prep_triple_quotes(s, mysplit=mysplit, replacements=replacements):
return ''.join(s)
def pretty_string(s, current_output, min_trip_str=20, max_line=100):
def pretty_string(s, embedded, current_output, min_trip_str=20, max_line=100):
"""There are a lot of reasons why we might not want to or
be able to return a triple-quoted string. We can always
punt back to the default normal string.
......@@ -91,6 +91,9 @@ def pretty_string(s, current_output, min_trip_str=20, max_line=100):
len_s = len(default)
current_line = _get_line(current_output)
if current_line.strip():
if embedded and '\n' not in s:
return default
if len_s < min_trip_str:
return default
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment