[pypy-commit] pypy py3k: Propagate no-NULness in str.replace()

amauryfa noreply at buildbot.pypy.org
Thu Nov 22 23:49:54 CET 2012


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r59047:6e9bda8ec6a6
Date: 2012-11-22 22:46 +0100
http://bitbucket.org/pypy/pypy/changeset/6e9bda8ec6a6/

Log:	Propagate no-NULness in str.replace()

diff --git a/pypy/annotation/test/test_annrpython.py b/pypy/annotation/test/test_annrpython.py
--- a/pypy/annotation/test/test_annrpython.py
+++ b/pypy/annotation/test/test_annrpython.py
@@ -3271,6 +3271,7 @@
         a = self.RPythonAnnotator()
         s = a.build_types(f, [str])
         assert isinstance(s, annmodel.SomeString)
+        assert s.no_nul
 
         def f(x):
             return u'a'.replace(x, u'b')
diff --git a/pypy/annotation/unaryop.py b/pypy/annotation/unaryop.py
--- a/pypy/annotation/unaryop.py
+++ b/pypy/annotation/unaryop.py
@@ -508,7 +508,7 @@
         return getbookkeeper().newlist(s_item)
 
     def method_replace(str, s1, s2):
-        return str.basestringclass()
+        return str.basestringclass(no_nul=str.no_nul and s2.no_nul)
 
     def getslice(str, s_start, s_stop):
         check_negative_slice(s_start, s_stop)


More information about the pypy-commit mailing list