[pypy-svn] r30132 - in pypy/dist/pypy/translator/cli: . test
antocuni at codespeak.net
antocuni at codespeak.net
Mon Jul 17 16:36:12 CEST 2006
Author: antocuni
Date: Mon Jul 17 16:36:04 2006
New Revision: 30132
Modified:
pypy/dist/pypy/translator/cli/support.py
pypy/dist/pypy/translator/cli/test/test_constant.py
Log:
mono can't handle non-printable chars inside string literals, so we
need to use the bytearray syntax instead.
Modified: pypy/dist/pypy/translator/cli/support.py
==============================================================================
--- pypy/dist/pypy/translator/cli/support.py (original)
+++ pypy/dist/pypy/translator/cli/support.py Mon Jul 17 16:36:04 2006
@@ -5,9 +5,14 @@
if ' ' <= c < '\x7F': return c
if c == '\n': return '\\n'
if c == '\t': return '\\t'
- return '\\%03o' % ord(c)
+ raise ValueError
def line_repr(s):
return ''.join([char_repr(c) for c in s])
+ def array_repr(s):
+ return ' '.join(['%x 00' % ord(c) for c in s+'\001'])
- return '"%s"' % line_repr(s)
+ try:
+ return '"%s"' % line_repr(s)
+ except ValueError:
+ return "bytearray ( %s )" % array_repr(s)
Modified: pypy/dist/pypy/translator/cli/test/test_constant.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/test_constant.py (original)
+++ pypy/dist/pypy/translator/cli/test/test_constant.py Mon Jul 17 16:36:04 2006
@@ -67,3 +67,9 @@
def fn():
return 'hello "world"'
assert self.ll_to_string(self.interpret(fn, [])) == 'hello "world"'
+
+ def test_string_literal2(self):
+ s = '\001\002\003'
+ def fn():
+ return ord(s[0]) + ord(s[1])
+ assert self.interpret(fn, []) == 3
More information about the Pypy-commit
mailing list