예제 #1
0
 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')
예제 #2
0
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))])
예제 #3
0
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))])
예제 #4
0
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))])
예제 #5
0
 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, '"')
예제 #6
0
 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, '"')
예제 #7
0
 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, '"')
예제 #8
0
 def tostring(self):
     from pypy.objspace.std.bytesobject import string_escape_encode
     out_encoded = string_escape_encode(self.source, '"')
     return '#px#%s' % out_encoded
예제 #9
0
 def tostring(self):
     from pypy.objspace.std.bytesobject import string_escape_encode
     out_encoded = string_escape_encode(self.source, '"')
     return '#px#%s' % out_encoded