Commits

Amaury Forgeot d'Arc committed 1c332c5

When the no_nul check is disabled, correctly transform the signature
when the function takes a list of strings.

Comments (0)

Files changed (2)

pypy/annotation/model.py

     return s_obj
 
 def remove_no_nul(s_obj):
+    if isinstance(s_obj, SomeList):
+        s_item = s_obj.listdef.read_item()
+        new_s_item = remove_no_nul(s_item)
+        from pypy.annotation.listdef import ListDef
+        if s_item is not new_s_item:
+            return SomeList(ListDef(None, new_s_item,
+                                    resized=True))
+
     if not getattr(s_obj, 'no_nul', False):
         return s_obj
     new_s_obj = SomeObject.__new__(s_obj.__class__)

pypy/rpython/test/test_extfunc.py

         raises(Exception, a.build_types, g, [str])
         a.build_types(g, [str0])  # Does not raise
 
+    def test_list_of_str0(self):
+        str0 = annmodel.SomeString(no_nul=True)
+        def os_execve(l):
+            pass
+        register_external(os_execve, [[str0]], None)
+        def f(l):
+            return os_execve(l)
+        policy = AnnotatorPolicy()
+        policy.allow_someobjects = False
+        a = RPythonAnnotator(policy=policy)
+        a.build_types(f, [[str]])  # Does not raise
+        assert a.translator.config.translation.check_str_without_nul == False
+        # Now enable the str0 check, and try again with a similar function
+        a.translator.config.translation.check_str_without_nul=True
+        def g(l):
+            return os_execve(l)
+        raises(Exception, a.build_types, g, [[str]])
+        a.build_types(g, [[str0]])  # Does not raise
+        
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.