def to_toplevel_string(self): if we_are_translated(): # HT Pycket from pypy.objspace.std.bytesobject import string_escape_encode return string_escape_encode(self.s, '"') else: return '"%s"' % self.s.encode('string_escape')
def escape_encode(space, data, errors='strict'): from pypy.objspace.std.bytesobject import string_escape_encode result = string_escape_encode(data, quote="'") start = 1 end = len(result) - 1 assert end >= 0 w_result = space.newbytes(result[start:end]) return space.newtuple([w_result, space.newint(len(data))])
def escape_encode(space, data, errors='strict'): from pypy.objspace.std.bytesobject import string_escape_encode result = string_escape_encode(data, quote="'") start = 1 end = len(result) - 1 assert end >= 0 w_result = space.wrap(result[start:end]) return space.newtuple([w_result, space.wrap(len(data))])
def escape_encode(space, data, errors='strict'): from pypy.objspace.std.bytesobject import string_escape_encode result = string_escape_encode(data, False) return space.newtuple([space.newbytes(result), space.newint(len(data))])
def tostring(self): from pypy.objspace.std.bytesobject import string_escape_encode r = self.as_str_utf8() assert r is not None return string_escape_encode(r, '"')
def tostring(self): # this function should really live in a slightly more accessible place from pypy.objspace.std.bytesobject import string_escape_encode return string_escape_encode(self.value, '"')
def tostring(self): from pypy.objspace.std.bytesobject import string_escape_encode out_encoded = string_escape_encode(self.source, '"') return '#px#%s' % out_encoded