[pypy-commit] pypy default: Test and fix

arigo noreply at buildbot.pypy.org
Wed Dec 24 16:57:54 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r75105:b950155cdd8a
Date: 2014-12-24 16:57 +0100
http://bitbucket.org/pypy/pypy/changeset/b950155cdd8a/

Log:	Test and fix

diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -254,7 +254,10 @@
         return self.__class__(can_be_None=False, no_nul=self.no_nul)
 
     def nonnulify(self):
-        return self.__class__(can_be_None=self.can_be_None, no_nul=True)
+        if self.can_be_None:
+            return self.__class__(can_be_None=True, no_nul=True)
+        else:
+            return self.__class__(no_nul=True)
 
 
 class SomeString(SomeStringOrUnicode):
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
@@ -4326,6 +4326,13 @@
         assert isinstance(s, annmodel.SomeString)
         assert not s.can_be_none()
 
+    def test_nonnulify(self):
+        s = annmodel.SomeString(can_be_None=True).nonnulify()
+        assert s.can_be_None is True
+        assert s.no_nul is True
+        s = annmodel.SomeChar().nonnulify()
+        assert s.no_nul is True
+
 
 def g(n):
     return [0, 1, 2, n]


More information about the pypy-commit mailing list