[pypy-commit] pypy py3k: hg merge default
antocuni
noreply at buildbot.pypy.org
Fri Aug 31 11:21:52 CEST 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r57051:83a304c73c9a
Date: 2012-08-31 11:20 +0200
http://bitbucket.org/pypy/pypy/changeset/83a304c73c9a/
Log: hg merge default
diff --git a/pypy/rpython/lltypesystem/rstr.py b/pypy/rpython/lltypesystem/rstr.py
--- a/pypy/rpython/lltypesystem/rstr.py
+++ b/pypy/rpython/lltypesystem/rstr.py
@@ -147,6 +147,7 @@
from pypy.rpython.annlowlevel import hlstr, llunicode
from pypy.rlib.runicode import str_decode_utf_8
value = hlstr(llvalue)
+ assert value is not None
univalue, _ = str_decode_utf_8(value, len(value), 'strict')
return llunicode(univalue)
@@ -199,6 +200,7 @@
from pypy.rpython.annlowlevel import hlunicode, llstr
from pypy.rlib.runicode import unicode_encode_utf_8
s = hlunicode(ll_s)
+ assert s is not None
bytes = unicode_encode_utf_8(s, len(s), 'strict')
return llstr(bytes)
diff --git a/pypy/rpython/ootypesystem/rstr.py b/pypy/rpython/ootypesystem/rstr.py
--- a/pypy/rpython/ootypesystem/rstr.py
+++ b/pypy/rpython/ootypesystem/rstr.py
@@ -64,6 +64,7 @@
from pypy.rpython.annlowlevel import hlstr, oounicode
from pypy.rlib.runicode import str_decode_utf_8
value = hlstr(llvalue)
+ assert value is not None
univalue, _ = str_decode_utf_8(value, len(value), 'strict')
return oounicode(univalue)
@@ -109,6 +110,7 @@
from pypy.rpython.annlowlevel import hlunicode, oostr
from pypy.rlib.runicode import unicode_encode_utf_8
s = hlunicode(ll_s)
+ assert s is not None
bytes = unicode_encode_utf_8(s, len(s), 'strict')
return oostr(bytes)
diff --git a/pypy/rpython/test/test_runicode.py b/pypy/rpython/test/test_runicode.py
--- a/pypy/rpython/test/test_runicode.py
+++ b/pypy/rpython/test/test_runicode.py
@@ -106,6 +106,20 @@
assert self.ll_to_string(self.interpret(f, [38])) == f(38)
+ def test_utf_8_encoding_annotation(self):
+ from pypy.rlib.runicode import unicode_encode_utf_8
+ def f(n):
+ x = u'àèì' + unichr(n)
+ if x:
+ y = u'ìòé'
+ else:
+ y = u'òìàà'
+ # the annotation of y is SomeUnicodeString(can_be_None=False)
+ y = unicode_encode_utf_8(y, len(y), 'strict')
+ return x.encode('utf-8') + y
+
+ assert self.ll_to_string(self.interpret(f, [38])) == f(38)
+
def test_unicode_encode_error(self):
def f(x, which):
if which:
@@ -139,6 +153,17 @@
assert self.ll_to_string(self.interpret(f, [0])) == f(0)
+ def test_utf_8_decoding_annotation(self):
+ from pypy.rlib.runicode import str_decode_utf_8
+ strings = [u'àèì'.encode('utf-8'), u'ìòéà'.encode('utf-8')]
+ def f(n):
+ x = strings[n]
+ # the annotation of y is SomeUnicodeString(can_be_None=False)
+ y, _ = str_decode_utf_8(x, len(x), 'strict')
+ return x.decode('utf-8') + y
+
+ assert self.ll_to_string(self.interpret(f, [1])) == f(1)
+
def test_unicode_decode_error(self):
def f(x):
y = 'xxx'
More information about the pypy-commit
mailing list