[pypy-svn] r48359 - in pypy/branch/pypy-rpython-unicode/annotation: . test

fijal at codespeak.net fijal at codespeak.net
Wed Nov 7 14:46:16 CET 2007


Author: fijal
Date: Wed Nov  7 14:46:16 2007
New Revision: 48359

Modified:
   pypy/branch/pypy-rpython-unicode/annotation/model.py
   pypy/branch/pypy-rpython-unicode/annotation/test/test_annrpython.py
   pypy/branch/pypy-rpython-unicode/annotation/unaryop.py
Log:
Fix thing that iteration over unicode returned chars


Modified: pypy/branch/pypy-rpython-unicode/annotation/model.py
==============================================================================
--- pypy/branch/pypy-rpython-unicode/annotation/model.py	(original)
+++ pypy/branch/pypy-rpython-unicode/annotation/model.py	Wed Nov  7 14:46:16 2007
@@ -217,9 +217,6 @@
     def nonnoneify(self):
         return SomeUnicodeString(can_be_None=False)
 
-SomeString.basestringclass = SomeString
-SomeUnicodeString.basestringclass = SomeUnicodeString
-
 class SomeChar(SomeString):
     "Stands for an object known to be a string of length 1."
 
@@ -228,6 +225,11 @@
     def can_be_none(self):
         return False
 
+SomeString.basestringclass = SomeString
+SomeString.basecharclass = SomeChar
+SomeUnicodeString.basestringclass = SomeUnicodeString
+SomeUnicodeString.basecharclass = SomeUnicodeCodePoint
+
 class SomeList(SomeObject):
     "Stands for a homogenous list of any length."
     knowntype = list

Modified: pypy/branch/pypy-rpython-unicode/annotation/test/test_annrpython.py
==============================================================================
--- pypy/branch/pypy-rpython-unicode/annotation/test/test_annrpython.py	(original)
+++ pypy/branch/pypy-rpython-unicode/annotation/test/test_annrpython.py	Wed Nov  7 14:46:16 2007
@@ -2951,6 +2951,16 @@
         s = a.build_types(f, [unicode])
         assert isinstance(s, annmodel.SomeUnicodeString)
 
+    def test_unicode_char(self):
+        def f(x, i):
+            for c in x:
+                if c == i:
+                    return c
+            return 'x'
+            
+        a = self.RPythonAnnotator()
+        s = a.build_types(f, [unicode, str])
+        assert isinstance(s, annmodel.SomeUnicodeCodePoint)
 
 def g(n):
     return [0,1,2,n]

Modified: pypy/branch/pypy-rpython-unicode/annotation/unaryop.py
==============================================================================
--- pypy/branch/pypy-rpython-unicode/annotation/unaryop.py	(original)
+++ pypy/branch/pypy-rpython-unicode/annotation/unaryop.py	Wed Nov  7 14:46:16 2007
@@ -449,7 +449,7 @@
     iter.can_only_throw = []
 
     def getanyitem(str):
-        return SomeChar()
+        return str.basecharclass()
 
     def ord(str):
         return SomeInteger(nonneg=True)



More information about the Pypy-commit mailing list