[pypy-svn] r49205 - in pypy/dist/pypy/annotation: . test

exarkun at codespeak.net exarkun at codespeak.net
Thu Nov 29 14:50:22 CET 2007


Author: exarkun
Date: Thu Nov 29 14:50:22 2007
New Revision: 49205

Modified:
   pypy/dist/pypy/annotation/binaryop.py
   pypy/dist/pypy/annotation/test/test_annrpython.py
Log:
fix NameError in success case for str % tuple

Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py	(original)
+++ pypy/dist/pypy/annotation/binaryop.py	Thu Nov 29 14:50:22 2007
@@ -451,7 +451,7 @@
             if isinstance(s_item, (SomeUnicodeCodePoint, SomeUnicodeString)):
                 raise NotImplementedError(
                     "string formatting mixing strings and unicode not supported")
-        getbookkeeper().count('strformat', str, args)
+        getbookkeeper().count('strformat', str, s_tuple)
         return SomeString()
 
 

Modified: pypy/dist/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/test/test_annrpython.py	(original)
+++ pypy/dist/pypy/annotation/test/test_annrpython.py	Thu Nov 29 14:50:22 2007
@@ -2985,6 +2985,19 @@
         py.test.raises(NotImplementedError, a.build_types, f, [int])
 
 
+    def test_strformatting_tuple(self):
+        """
+        A function which returns the result of interpolating a tuple of a
+        single str into a str format string should be annotated as returning
+        SomeString.
+        """
+        def f(x):
+            return '%s' % (x,)
+
+        a = self.RPythonAnnotator()
+        s = a.build_types(f, [str])
+        assert isinstance(s, annmodel.SomeString)
+
 
     def test_negative_slice(self):
         def f(s, e):



More information about the Pypy-commit mailing list