Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r85499:850a4e0a56cc Date: 2016-07-01 19:37 +0200 http://bitbucket.org/pypy/pypy/changeset/850a4e0a56cc/
Log: Support backslashes inside strings passed to dot diff --git a/rpython/translator/tool/make_dot.py b/rpython/translator/tool/make_dot.py --- a/rpython/translator/tool/make_dot.py +++ b/rpython/translator/tool/make_dot.py @@ -51,7 +51,7 @@ ports=None, ): d = locals() - attrs = [('%s="%s"' % (x, d[x].replace('"', '\\"').replace('\n', '\\n'))) + attrs = [('%s="%s"' % (x, _quote(d[x]))) for x in ['label', 'style', 'color', 'dir', 'weight']] self.emit('edge [%s];' % ", ".join(attrs)) if ports: @@ -69,7 +69,7 @@ width="0.75", ): d = locals() - attrs = [('%s="%s"' % (x, d[x].replace('"', '\\"').replace('\n', '\\n'))) + attrs = [('%s="%s"' % (x, _quote(d[x]))) for x in ['shape', 'label', 'color', 'fillcolor', 'style', 'width']] self.emit('%s [%s];' % (safename(name), ", ".join(attrs))) @@ -193,7 +193,7 @@ name2 = self.blockname(link.target) label = " ".join(map(repr, link.args)) if link.exitcase is not None: - label = "%s: %s" %(repr(link.exitcase).replace('\\', '\\\\'), label) + label = "%s: %s" %(_quote(repr(link.exitcase)), label) self.emit_edge(name, name2, label, style="dotted", color="red") else: self.emit_edge(name, name2, label, style="solid") @@ -237,3 +237,6 @@ # not a keyword name = ''.join([CHAR_MAP[c] for c in name]) return '_' + name + +def _quote(s): + return s.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n') _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit