[pypy-commit] pypy py3k: hg merge default

antocuni noreply at buildbot.pypy.org
Thu Jul 19 00:43:58 CEST 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r56204:527bcbf32b7a
Date: 2012-07-19 00:43 +0200
http://bitbucket.org/pypy/pypy/changeset/527bcbf32b7a/

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
@@ -174,7 +174,7 @@
         if s:
             return s
         else:
-            return self.convert_const(u'None')
+            return self.ll.ll_constant(u'None')
 
     @jit.elidable
     def ll_encode_latin1(self, s):
@@ -964,7 +964,12 @@
         return LLHelpers.ll_join_strs(len(builder), builder)
 
     def ll_constant(s):
-        return string_repr.convert_const(s)
+        if isinstance(s, str):
+            return string_repr.convert_const(s)
+        elif isinstance(s, unicode):
+            return unicode_repr.convert_const(s)
+        else:
+            assert False
     ll_constant._annspecialcase_ = 'specialize:memo'
 
     def do_stringformat(cls, hop, sourcevarsrepr):
diff --git a/pypy/rpython/ootypesystem/ooregistry.py b/pypy/rpython/ootypesystem/ooregistry.py
--- a/pypy/rpython/ootypesystem/ooregistry.py
+++ b/pypy/rpython/ootypesystem/ooregistry.py
@@ -47,7 +47,7 @@
     _type_ = ootype._string
 
     def compute_annotation(self):
-        return annmodel.SomeOOInstance(ootype=ootype.String)
+        return annmodel.SomeOOInstance(ootype=ootype.typeOf(self.instance))
 
 
 class Entry_ooparse_int(ExtRegistryEntry):
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
@@ -84,7 +84,7 @@
         if s:
             return s
         else:
-            return self.convert_const(u'None')
+            return self.ll.ll_constant(u'None')
 
     def ll_encode_latin1(self, value):
         sb = ootype.new(ootype.StringBuilder)
@@ -311,7 +311,12 @@
         return buf.ll_build()
 
     def ll_constant(s):
-        return ootype.make_string(s)
+        if isinstance(s, str):
+            return ootype.make_string(s)
+        elif isinstance(s, unicode):
+            return ootype.make_unicode(s)
+        else:
+            assert False
     ll_constant._annspecialcase_ = 'specialize:memo'
 
     def do_stringformat(cls, hop, sourcevarsrepr):
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
@@ -198,12 +198,16 @@
 
     def test_strformat_unicode_arg(self):
         const = self.const
-        def percentS(s):
+        def percentS(s, i):
+            s = [s, None][i]
             return const("before %s after") % (s,)
         #
-        res = self.interpret(percentS, [const(u'&#224;')])
+        res = self.interpret(percentS, [const(u'&#224;'), 0])
         assert self.ll_to_string(res) == const(u'before &#224; after')
         #
+        res = self.interpret(percentS, [const(u'&#224;'), 1])
+        assert self.ll_to_string(res) == const(u'before None after')
+        #
 
     def unsupported(self):
         py.test.skip("not supported")


More information about the pypy-commit mailing list