[pypy-commit] pypy py3k: Fix no_nul-ness of importing.make_compiled_pathname()

amauryfa noreply at buildbot.pypy.org
Sun Feb 5 23:32:33 CET 2012


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r52117:4e8b55a8b643
Date: 2012-02-05 19:51 +0100
http://bitbucket.org/pypy/pypy/changeset/4e8b55a8b643/

Log:	Fix no_nul-ness of importing.make_compiled_pathname()

diff --git a/pypy/annotation/binaryop.py b/pypy/annotation/binaryop.py
--- a/pypy/annotation/binaryop.py
+++ b/pypy/annotation/binaryop.py
@@ -448,7 +448,8 @@
 class __extend__(pairtype(SomeChar, SomeChar)):
 
     def union((chr1, chr2)):
-        return SomeChar()
+        no_nul = chr1.no_nul and chr2.no_nul
+        return SomeChar(no_nul=no_nul)
 
 
 class __extend__(pairtype(SomeChar, SomeUnicodeCodePoint),
@@ -645,14 +646,14 @@
 
     def getitem((str1, int2)):
         getbookkeeper().count("str_getitem", int2)        
-        return SomeChar()
+        return SomeChar(no_nul=str1.no_nul)
     getitem.can_only_throw = []
 
     getitem_key = getitem
 
     def getitem_idx((str1, int2)):
         getbookkeeper().count("str_getitem", int2)        
-        return SomeChar()        
+        return SomeChar(no_nul=str1.no_nul)
     getitem_idx.can_only_throw = [IndexError]
 
     getitem_idx_key = getitem_idx
diff --git a/pypy/module/imp/interp_imp.py b/pypy/module/imp/interp_imp.py
--- a/pypy/module/imp/interp_imp.py
+++ b/pypy/module/imp/interp_imp.py
@@ -181,7 +181,7 @@
     if space.config.objspace.usemodules.thread:
         importing.getimportlock(space).reinit_lock()
 
- at unwrap_spec(pathname=str)
+ at unwrap_spec(pathname='str0')
 def cache_from_source(space, pathname, w_debug_override=None):
     """cache_from_source(path, [debug_override]) -> path
     Given the path to a .py file, return the path to its .pyc/.pyo file.
@@ -194,7 +194,7 @@
     the value of __debug__ instead."""
     return space.wrap(importing.make_compiled_pathname(pathname))
 
- at unwrap_spec(pathname=str)
+ at unwrap_spec(pathname='str0')
 def source_from_cache(space, pathname):
     """source_from_cache(path) -> path
     Given the path to a .pyc./.pyo file, return the path to its .py file.
diff --git a/pypy/module/imp/test/test_import.py b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -980,6 +980,16 @@
                 finally:
                     stream.close()
 
+    def test_annotation(self):
+        from pypy.annotation.annrpython import RPythonAnnotator
+        from pypy.annotation import model as annmodel
+        def f():
+            return importing.make_compiled_pathname('abc/foo.py')
+        a = RPythonAnnotator()
+        s = a.build_types(f, [])
+        assert isinstance(s, annmodel.SomeString)
+        assert s.no_nul
+
 
 def test_PYTHONPATH_takes_precedence(space): 
     if sys.platform == "win32":


More information about the pypy-commit mailing list