Author: Carl Friedrich Bolz <cfb...@gmx.de>
Branch: 
Changeset: r78887:8700b302673f
Date: 2015-08-11 12:45 +0200
http://bitbucket.org/pypy/pypy/changeset/8700b302673f/

Log:    (cfbolz, arigo): fix no nul propagation of modulo of strings and
        non-tuples

diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -425,8 +425,9 @@
 class __extend__(pairtype(SomeString, SomeObject),
                  pairtype(SomeUnicodeString, SomeObject)):
 
-    def mod((s_string, args)):
-        return s_string.__class__()
+    def mod((s_string, s_arg)):
+        assert not isinstance(s_arg, SomeTuple)
+        return pair(s_string, SomeTuple([s_arg])).mod()
 
 class __extend__(pairtype(SomeFloat, SomeFloat)):
 
diff --git a/rpython/annotator/test/test_annrpython.py 
b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -2124,6 +2124,16 @@
         assert isinstance(s, annmodel.SomeString)
         assert s.no_nul
 
+    def test_no_nul_mod(self):
+        def f(x):
+            s = "%d" % x
+            return s
+        a = self.RPythonAnnotator()
+        s = a.build_types(f, [int])
+        assert isinstance(s, annmodel.SomeString)
+        assert s.no_nul
+
+
     def test_mul_str0(self):
         def f(s):
             return s*10
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to