Author: Amaury Forgeot d'Arc <[email protected]>
Branch: 
Changeset: r60632:56b7dba4721d
Date: 2013-01-28 20:52 +0100
http://bitbucket.org/pypy/pypy/changeset/56b7dba4721d/

Log:    Add str0 and unicode0 to signature types.

diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -113,6 +113,9 @@
         if policy is None:
             from rpython.annotator.policy import AnnotatorPolicy
             policy = AnnotatorPolicy()
+            # XXX hack
+            annmodel.TLS.check_str_without_nul = (
+                self.translator.config.translation.check_str_without_nul)
         graph, inputcells = self.get_call_parameters(function, args_s, policy)
         self.build_graph_types(graph, inputcells, complete_now=False)
         self.complete_helpers(policy)
diff --git a/rpython/rlib/test/test_signature.py 
b/rpython/rlib/test/test_signature.py
--- a/rpython/rlib/test/test_signature.py
+++ b/rpython/rlib/test/test_signature.py
@@ -9,6 +9,7 @@
 
 def annotate_at(f, policy=None):
     t = TranslationContext()
+    t.config.translation.check_str_without_nul = True
     a = t.buildannotator(policy=policy)
     a.annotate_helper(f, [model.s_ImpossibleValue]*f.func_code.co_argcount, 
policy=policy)
     return a
@@ -112,6 +113,12 @@
         return len(u)
     assert getsig(f) == [model.SomeUnicodeString(), model.SomeInteger()]
 
+def test_str0():
+    @signature(types.unicode0(), returns=types.str0())
+    def f(u):
+        return 'str'
+    assert getsig(f) == [model.SomeUnicodeString(no_nul=True),
+                         model.SomeString(no_nul=True)]
 
 def test_ptr():
     policy = LowLevelAnnotatorPolicy()
diff --git a/rpython/rlib/types.py b/rpython/rlib/types.py
--- a/rpython/rlib/types.py
+++ b/rpython/rlib/types.py
@@ -24,9 +24,15 @@
 def unicode():
     return model.SomeUnicodeString()
 
+def unicode0():
+    return model.SomeUnicodeString(no_nul=True)
+
 def str():
     return model.SomeString()
 
+def str0():
+    return model.SomeString(no_nul=True)
+
 def char():
     return model.SomeChar()
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to