From 453436367103dd9deb693da5b5ebb18c2c2c86ce Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 29 Jul 2016 19:54:44 -0700 Subject: add escape_single_quotes=False arg to bytes_to_escaped_str --- pathod/language/base.py | 8 ++++---- pathod/pathoc.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'pathod') diff --git a/pathod/language/base.py b/pathod/language/base.py index 25f3fd1a..39155858 100644 --- a/pathod/language/base.py +++ b/pathod/language/base.py @@ -136,7 +136,7 @@ class TokValueLiteral(_TokValueLiteral): def spec(self): inner = strutils.bytes_to_escaped_str(self.val) - inner = inner.replace(r"\'", r"\x27") + inner = inner.replace(r"'", r"\x27") return "'" + inner + "'" @@ -148,7 +148,7 @@ class TokValueNakedLiteral(_TokValueLiteral): return e.setParseAction(lambda x: cls(*x)) def spec(self): - return strutils.bytes_to_escaped_str(self.val) + return strutils.bytes_to_escaped_str(self.val, escape_single_quotes=True) class TokValueGenerate(Token): @@ -166,7 +166,7 @@ class TokValueGenerate(Token): def freeze(self, settings): g = self.get_generator(settings) - return TokValueLiteral(strutils.bytes_to_escaped_str(g[:])) + return TokValueLiteral(strutils.bytes_to_escaped_str(g[:], escape_single_quotes=True)) @classmethod def expr(cls): @@ -578,4 +578,4 @@ class NestedMessage(Token): def freeze(self, settings): f = self.parsed.freeze(settings).spec() - return self.__class__(TokValueLiteral(strutils.bytes_to_escaped_str(f.encode()))) + return self.__class__(TokValueLiteral(strutils.bytes_to_escaped_str(f.encode(), escape_single_quotes=True))) diff --git a/pathod/pathoc.py b/pathod/pathoc.py index c6783878..5831ba3e 100644 --- a/pathod/pathoc.py +++ b/pathod/pathoc.py @@ -444,7 +444,7 @@ class Pathoc(tcp.TCPClient): finally: if resp: lg("<< %s %s: %s bytes" % ( - resp.status_code, strutils.bytes_to_escaped_str(resp.reason.encode()), len(resp.content) + resp.status_code, strutils.escape_control_characters(resp.reason) if resp.reason else "", len(resp.content) )) if resp.status_code in self.ignorecodes: lg.suppress() -- cgit v1.2.3